Jquery ajax - Check errors on server with php
I hope someone can give me an advice about how to do the following:
I have a form with some fields that I want to check (validate) on the server using Ajax - the Jquery way.
Of course what I would expect form the callback is to know if each field has bee开发者_Go百科n correctly filled and thus validates.
I never done this before. Can anyone advice me what is the best way to do this?
Many thank for any help. Francesco
Jquery ajax has a error attr:
$.ajax({
url: 'youscript.php',
success: function(data) {
//whatever you want
},
error: function(data) {
//this will be fired on error
}
});
of course you can use any form validation plugin, but if the error occurs on server side, or if the user disable (somehow) your form validation plugin and the server side scripts fire up an error, the error
attr should do what you want.
This is the best jQuery ajax form submission plugin I've used.
http://jquery.malsup.com/form/
Check out the examples page.
精彩评论