开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜