如何在jQuery异步中提交表单?

Ita*_*vka 13 forms ajax jquery

在mootools我会做一些像$('form_id').send({success:function(res){....}}); jQuery中的并行语法是什么?

换句话说:
我如何将表单数据(假设id ='bob')放入以下代码中

$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType
});
Run Code Online (Sandbox Code Playgroud)

nas*_*ski 20

这应该这样做:

$.ajax({   
   type: 'POST',   
   url: url,   
   data: $('#bob').serialize(),
   success: success,
   dataType: dataType 
}); 
Run Code Online (Sandbox Code Playgroud)


Mat*_*rte 7

你不知道吗...它就在文档中!:P

http://api.jquery.com/jQuery.ajax/

编辑:好的没关系......

$('#too_cool_form').submit(function(e){
  e.preventDefault();
  //do some verification
  $.ajax({
    url: '',
    data: $(this).serialize(),
    success: function(data)
    {
      //callback methods go right here
    }
  });
});
Run Code Online (Sandbox Code Playgroud)