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

69
Views
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
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!