Jquery ';ajax:success';回调不起作用
当我提交表格时,我想在表格成功时获得成功。我正在使用 未触发成功警报:(.Jquery ';ajax:success';回调不起作用,jquery,Jquery,当我提交表格时,我想在表格成功时获得成功。我正在使用 未触发成功警报:(. 为什么?您好吗?在我看来,您实际上并没有使用AJAX提交表单,因为submit()函数将触发表单的正常提交。您能试试下面的代码吗 $('#new_invitation').live('submit', function(event){ event.preventDefault(); //Stops the normal form submission process form = $(this); data
为什么?您好吗?在我看来,您实际上并没有使用AJAX提交表单,因为submit()函数将触发表单的正常提交。您能试试下面的代码吗
$('#new_invitation').live('submit', function(event){
event.preventDefault(); //Stops the normal form submission process
form = $(this);
data = form.serialize(); //serializes the form data
jQuery.ajax({
type: 'POST',
dataType: 'JSON', // JSON, HTML, whatever your API responds to
url: form.attr('action'), //fetches the URL from the form
success: function(data,textStatus,jqXHR){
//Success callback
alert('success');
}
});
});
这假设“#new_invitation”是表单标签的ID。我建议您看看jQuery文档站点,它们有大量关于AJAX的信息:
祝您好运!谢谢您问题已解决:D.我必须填写此表单。
$('form[data method=“delete”]').live('ajax:success',function(){});
$('#new_invitation').live('submit', function(event){
event.preventDefault(); //Stops the normal form submission process
form = $(this);
data = form.serialize(); //serializes the form data
jQuery.ajax({
type: 'POST',
dataType: 'JSON', // JSON, HTML, whatever your API responds to
url: form.attr('action'), //fetches the URL from the form
success: function(data,textStatus,jqXHR){
//Success callback
alert('success');
}
});
});