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

  • Home
  • SEARCH
  • 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 6054839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:11:53+00:00 2026-05-23T08:11:53+00:00

If I have a JS function as follows; function testFn() { x.ajaxMethod(param1,JScallBackFunction); //Please do

  • 0

If I have a JS function as follows;

function testFn()
{
x.ajaxMethod(param1,JScallBackFunction); //Please do not worry about the syntax..this just indicates an external method call
alert("Line after ajaxMethod");
}

The ajaxMethod(), lets say is some kind of method defined in an external Java file (so it can be through DWR or anything) which returns some data…Point is it takes some time to execute this line of code…

Now my question is when will the alert on next line get fired (i.e. alert("Line after ajaxMethod");)

  1. Will it wait for these 2 things to complete (ajaxMethod execution as well as JScallBackFunction)
    OR
  2. It will be fired immediately without waiting for any of the above 2 things to complete ?

Also if you could guide in general about the JavaScript method flow execution, that will be great.

  • 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-23T08:11:54+00:00Added an answer on May 23, 2026 at 8:11 am

    It depends. Ajax calls are usually asynchronous which means the execution of code will not be paused until the asynchronous function returns. Therefore the alert will be executed immediately.

    Asynchronous functions in javascript are usually to do with Ajax and loading something from a remote server. If you do wish to force JavaScript to wait while loading that content then you can set a flag for the XMLHTTPRequest object.

    this is a good question to read: When is JavaScript synchronous?

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

Sidebar

Related Questions

I have this function whose essential operations are outlined as follows: function render($index) {
I have a generic function for XMLHttpRequests. as follows: function XMLRequest(address, data){ this.html =
I have a function in a native DLL defined as follows: #include <string> void
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I have a function that is set up as follows function mainFunction() { function
I have a function that uses the ... rest argument as follows: public function
I have a function, as follows: f.factor <- function(x) { print(length(unique(x))) z <- 1
I have a function as follows: function textNext(element, num) { document.getElementById(lblContent).innerHTML = hello; }
I have logging function as follows. logging.basicConfig( filename = fileName, format = %(levelname) -10s
I have a slow function that does an AJAX request: function X(param1,param2){ var params={

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.