I have to send some data to server in JQuery and I’m lost in a lot of functions like .ajax, .post, etc.
The conditions are very easy: a form must be sent synchronously, it won’t return any value, but if there is an error we have to stop sending more data (really, I am sending a bunch of forms).
So, the question is: which is the best function to do it and which are the minimum parameters I have to use?
At the moment, my approach is this:
$.ajax({
url: form.attr('action'),
type: 'POST',
data: form.serialize(),
async: false,
});
but as you can see, I’m not getting a return value if error.
How about calling asynchronously, but recursively:
Each HTTP Request that doesn’t return OK stops further data exchange (as the function is called again only on a HTTP status of
200 OK).