I’m writing some JavaScript/AJAX code.
Is there anyway to ensure that the server receives the XML requests in the order that they are sent?
If not with plain Ajax, do I get this guarantee if I send everything over a single WebSocket?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If it is of utmost importance that they’re received in the proper order, and attaching an iterating id to the form isn’t enough:
Then I’d suggest building your own queue-system, and send each subsequent file as the callback of the previous one.
Rather than each element having its own AJAX-access, create one centralized spot in your application to handle that.
Your different AJAX-enabled sections don’t even need to know that it is a queue:
On the other side of that, you could have something like:
Inside of your sync queue, all you’d need to do is wrap a new function around the old callback:
Inside of
checkQueue, you’d just need to see if it was empty, and if it wasn’t, usenextObj = queue.shift();(if you’re.push()-ing objects onto the queue — so first-in, first-out, like you wanted).