I am using asp.net-generated javascript wrappers for asp.net web servic开发者_开发技巧es. In javascript, how to "wait"
for several async web services wrappers to finished returning some json data? Is there a general and elegant way in javascript to deal with waiting for async functions ?
I have tried using jquery $.ajax
, which has an option to use sync rather than async. What is the pro and cons for using sync $.ajax mode
?
I know that each wrapper takes a success event handler and a failure event handler . But I found the nesting of many success event handlers hard to read . I wonder if other users find the nesting awkward ...
What is the pro and cons for using sync $.ajax mode ?
The con is that in all browsers (except Chrome, AFAIK), there's only a single thread for processing JavaScript, so while you wait synchronously for your web service call to complete, your page will be completely unresponsive. This is the type of situation that leads to an "unresponsive script" warning in the browser that can end up causing users to halt your JavaScript while it's executing, or close your site completely.
精彩评论