user670800
user670800

Reputation: 1115

asp.net web services javascript wrapper async problem

I am using asp.net-generated javascript wrappers for asp.net web services. 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 ...

Upvotes: 2

Views: 438

Answers (1)

Joel C
Joel C

Reputation: 5567

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.

Upvotes: 2

Related Questions