Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

65
Views
La solicitud de Ember Ajax no espera la respuesta

Aquí estoy llamando a una solicitud AJAX con este método "Security.createAuthenticatedAjaxRequest(session, URL)" y quiero devolver la respuesta de esa solicitud. Pero, parece que la respuesta no espera hasta que se complete la solicitud. Devuelve indefinido como respuesta. Creo que es porque devuelve la respuesta antes de que se complete la solicitud de ajax.

 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; }

Este es el método que ejecuta la solicitud AJAX.

 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); },

Aquí está el código donde usa la respuesta de la solicitud AJAX.

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

No tengo mucha experiencia con Ember js. ¿Puede alguien por favor ayudarme a resolver este problema?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!