I’m working with prototype.js and have the code like below..
new Ajax.Request('url', {
asynchronous: true,
method: "get",
onSuccess: Succeeded,
onFailure: Error
});
Problem occurs if the first requests’ finishing and the next same request issued.
How can I prevent requests with same url issued unless ‘Succeeded’ is called?
Of course, I can fix the problem by making the change of ‘asynchronous: false’, but is it possible asynchronous method still applies given the situation?
Thanks,
I always use asynchronous requests, as a synchronous request is rarely what you want.
I’m curious as to why the same request could be done more than once. Usually I just repeat the request in the error callback and signal success in the success callback. I use an abort timeout so I’m not waiting forever (default HTTP timeout is 2 minutes usually).
If the request is user initiated and therefore could happen more than once, you’d have to do this check manually (set an “inProgress” boolean somewhere).