Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3339198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:27:52+00:00 2026-05-18T00:27:52+00:00

Where does the jquery ajax success callback return to? I have written a request

  • 0

Where does the jquery ajax success callback return to?


I have written a request method that makes an ajax call, detects if I have supplied a callback or returns the datanode of the response XML.

Request Method:

function request(request, dontRefresh)
{     
   var requestXML = composeRequestXML(request); 
   $.ajax({
      url: 'someProcessor.php',
      type: 'POST',
      cache: false,
      async: dontRefresh,
      timeout: 5000,
      data: "query="+requestXML,
      success: function(response)
      {
         //parses xml into a js object
         var responseObj = parseResponseXML(response);

         if(request.callback){
            request.callback(responseObj);
         } else {
            // responseObj.response[0].data[0] is the data 
            // node of the response Obj.
            // this is what i see being the problem - 
            // I DON'T KNOW WHERE THIS IS RETURNED TO!!
            return responseObj.response[0].data[0];
         }
      }
   });
}

This request would use the callback

var requestObj = new Object();
    requestObj.callback = function(responseObj){someCallbackFunction(responseObj);};
    requestObj[0] = new Object();
    requestObj[0].module = "someModule";
    requestObj[0].action = "someModuleMethod";
request(requestObj);
//results are returned to the function someCallbackFunction()

This is an example of what i’d like to accomplish

var requestObj = new Object();
    requestObj[0] = new Object();
    requestObj[0].module = "userManager";
    requestObj[0].action = "GET_USERID";

var userId = request(requestObj, false); //make the request asynchronous

I’ve tried returning the $.ajax() function itself… like so:

function request(request, dontRefresh){
   return $.ajax({/*...options...*/);
}

But this bypasses the xml parser I have developed and returns the XHR object. I would like to use this kind of technique to register variables. So essentially…

I will be using this method with a callback or setting a variable with it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:27:52+00:00Added an answer on May 18, 2026 at 12:27 am

    It gets returned to jquery, and jquery discards it. If you want to make your code stop until something has been loaded, use synchronous ajax. But that makes the page irresponsive until the ajax request is complete, so please don’t do it!

    Example of synchronous ajax (without jquery):

    var ajax=new XMLHttpRequest();
    ajax.open("GET", url, false);
    ajax.send(null);
    return ajax.responseText;
    

    Note: For IE compatibility, this gets a little bit more complicated, this is just a proof of concept. And this would be the jquery way of doing it: How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery ajax request in a .js file: $.ajax({ type: GET,
Does anyone know of some good tutorials that explain how to use the JQuery
I have the following JQuery code which does similar functionality like Stackoverflow where the
With the jQuery datepicker, how does one change the year range that is displayed?
I am working on a project where I have to send an ajax request
Does anyone know how to stop jQuery fromparsing html you insert through before() and
Does anyone know of an easy way to escape HTML from strings in jQuery
I am trying to get an element using JQuery's selector, but it does not
Does Google force employees who have offers from Facebook to leave immediately?
Does the Java language have delegate features, similar to how C# has support for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.