Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

64
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda