Hi, I am calling a third party webservice using getJSON callback. The function donot 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. Thanks Shyama
Are you using jQuery .ajax(), if so use "success:" in the .ajax() form and determine the function Or, you could set a trigger var to false, and when the JSON is processed, set it to true and run the other functions
Thanks!! but the issue is I don't have control over jQuery JSON callback function. So i cannot use "success:" in .ajax. My requirment is that no javascript function should execute till I receive the response from JSON callback. Is there anyway I can explicity call success function from my page?
Only if you're using AJAX. Then it's inherent - the page you call sends back a status 200, which jQuery uses to run the success function. If the page you're calling doesn't throw a status 200, use another site - whoever butchered ("wrote" is too elegant for what they did) that site can't be trusted. If you're not using AJAX, put what you get into a variable that's blank or null until the JSON return. Loop on the variable being empty. (That could hang the page, though, if the data connection is lost.) Calling another site that doesn't signal that it's returning data is a bad idea.