开发者

Save button with Ajax

开发者 https://www.devze.com 2023-03-01 08:41 出处:网络
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 wil

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

精彩评论

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