Save button with Ajax
I'm making an开发者_运维技巧 online form for customers and now adding a submit button which saves the record in database. Is there any way i can submit data using AJAX ?
Take a look at jQuery. It will do the job for you.
Here is some sample jQuery code which may help:
$('.submitter').click(function() {
$.ajax({
'url' : 'url.php',
'type' : 'POST',
'data' : $('.myForm').serialize(), //Gets all of the values from a form
'success' : function(data) {
if (data == 'saved') {
alert('Form was saved!');
}
}
});
});
Hope that helps,
spryno724
精彩评论