Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

66
Visualizações
Ember Ajax request doesn't wait for the response

Here I'm calling an AJAX request with this "Security.createAuthenticatedAjaxRequest(session, URL)" method and I want to return the response of that request. But, it seems like the response doesn't wait until the request completes. It returns undefined as the response. I think it's because it returns the response before ajax request completes.

function minAndMaxGradeAllowedRequest(session) {   
    if (Common.isEmpty(minAndMaxGradeAllowed)) {
        Security.createAuthenticatedAjaxRequest(session,URL)
       .then(function(minAndMaxGradeAllowedResponse) {
            minAndMaxGradeAllowed =minAndMaxGradeAllowedResponse;})
       .fail(function(error) {
            LOGGER('Failed to find Shaywitz Min and Max grades 
            information', error.toString());
       });   
     }   
     return minAndMaxGradeAllowed; 
}

This is the method which executes the AJAX request.

createAuthenticatedAjaxRequest: function(session, url, config){
    if(Common.isEmpty(config)) {
        config = {};
     }
     return this.createAuthenticatedAjaxRequestWithAcceptHeaderParam(session, url, config, true);
},


createAuthenticatedAjaxRequestWithAcceptHeaderParam: function(session, url, config, isAcceptRequired){
  if(Common.isEmpty(config)) {
    config = {};
  }

  if(Common.isEmpty(config.headers)) {
    config.headers = {};
  }

  config.headers['Authorization'] = 'Bearer ' + session.get('data.authenticated.access_token');
  if(!Common.isEmpty(isAcceptRequired) &&  isAcceptRequired  === true) {
    config.headers['Accept'] = 'application/json';
  }

  if(Common.isNotEmpty(session.get('data.authenticated.supportuser'))){
    config.headers['supportuser'] = session.get('data.authenticated.supportuser');
  }

  return Ember.$.ajax(url, config);
},  

  

Here is the code where it uses the response of the AJAX request.

let minAndMaxGradeAllowed = ShaywitzGradesAllowed.getMinAndMaxGradeAllowed(this.get('session'));

I don't have much experience with Ember js. Can someone please help me to solve this problem?

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda