3

I am calling a third party webservice using getJSON callback. The function does not have a success handler attached to the function and since it is third party, I cannot edit the code also. By the time I receive the response, some of the javascript function in the page already executes.

Is there any way I can delay the execution of the Javascript function till I receive the response data from web service except setTimeout method.

Sumurai8
  • 19,483
  • 10
  • 67
  • 96
Shyama
  • 31
  • 3

2 Answers2

3

Description

You can use jQuery's .ajaxStart() and .ajaxComplete() events to get noticed if your ajax call is running. You can create a bool variable, something like isAjaxRunning and put this around the other javascript. So if isAjaxRunning is true, dont execute other javascript.

More Information

Community
  • 1
  • 1
dknaack
  • 58,548
  • 26
  • 144
  • 194
1

if you have access to the code you can make it synchonize by adding the attribute

async : false - then it won't be a asynchronous call like the normal ajax .

If you can post the sample code - that will give a clear picture.

Vins
  • 1,801
  • 15
  • 14