开发者

Ajax Concurrent calls

开发者 https://www.devze.com 2023-03-02 12:29 出处:网络
How can I make c开发者_如何学编程oncurrent ajax calls.When I try to do that its happening one after one in sequential manner.

How can I make c开发者_如何学编程oncurrent ajax calls.When I try to do that its happening one after one in sequential manner.

I have made two ajax calls to two different jsps to get response.In first jsp for first ajax call I used following code. int i = 5000; while (i == 0) { out.println(i); i--; }

For second ajax call i used following code to get response. int i = 5; while (i == 0) { out.println(i); i--; }

Response from second call suppose to come first.But response from second call comes after first one is executed.How can I make them concurrent.


That depends on the browser the client is using - I've come across this problem before - older browsers don't thread things very well.

Best advice I can give is to use JQuery... I think that sorted out my problems when I came across that behaviour, though not for all browsers.


Use asynchronous calls instead of synchronous.

But do be careful in structuring your code to ensure, one section doesn't rely on values set by the other as it's not guaranteed what code is being executed at any given time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号