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 8717845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:23:19+00:00 2026-06-13T06:23:19+00:00

Possible Duplicate: How to return AJAX response Text? I’m calling a javascript method which

  • 0

Possible Duplicate:
How to return AJAX response Text?

I’m calling a javascript method which in turn sends Ajax request and gives response.I’m getting the result in callback method like “success”.
Here Ajax is returning some result, in the mean while javascript method returning result (something as undefined).
But it should return ajax result only.
The problem i was identified is, Javascript and Ajax are both concurrently executing.
How to stop them and first execut Ajax and it’s result must send to function which returns the result.
Any idea is Highly Appreciated.. 🙂

  • 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-06-13T06:23:19+00:00Added an answer on June 13, 2026 at 6:23 am

    By default, $.ajax (and anything that uses it, such as $.post) makes asynchronous requests. You can make the request synchronous by specifying async:false (see documentation). I don’t recommend you use synchronous AJAX requests, though, as it degrades performance and leads to poor user experience. Instead, consider using a callback which is invoked in your success handler when the result is complete.

    Here are two arbitrary and simple examples, where we have an anchor that we want to have the text replaced from the result of an AJAX call when clicked. Both do the same thing, but the second one is preferred because it keeps the browser responsive.

    Synchronous:

    function invokeAjaxSync() {
       var text;
    
       $.ajax({url: '/path/to/resource', async:false, success: function(result) {
          text = result.toString();
       }}); // will wait until this call is complete
    
       return text;
    }
    
    $('a.example').click(function() {
        $(this).text(invokeAjaxSync()); // works, but the browser will be unresponsive while waiting for a response.
    });
    

    Asynchronous (better):

    function invokeAjaxAsync(callback) { 
       $.ajax({url:'/path/to/resource', success: function(result) {
             callback(result);
       }});
    }
    
    
    $('a.example').click(function() {
         var $this = $(this);
    
         invokeAjaxAsync(function(result) {
            $this.text(result.toString());
         }); // browser will remain responsive, but still update text when the AJAX call completes.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: jQuery: Return data after ajax call success I wrote a script which
Possible Duplicate: Ajax cross domain call I have Asp.Net Controller methods which return JSON
Possible Duplicate: return AJAX callback return I have made a JQuery code using AJAX,
Possible Duplicate: JavaScript: why does parseInt(1/0, 19) return 18? Why does parseInt(1/0, 19) evaluate
Possible Duplicate: jquery ajax return: undefined I have written the following code to check
Possible Duplicate: Kill Ajax requests using JavaScript using jQuery Here is the simple code
Possible Duplicate: URL redirection in Java return 302 instead of 301 response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response.sendRedirect(redirectUrl); I
Possible Duplicate: jQuery and AJAX response header If the server is returned data in
Possible Duplicate: jQuery: Return data after ajax call success I have the following function
Possible Duplicate: Return Value from inside of $.ajax() function I'm working on a CakePHP

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.