我正在做以下事情:
// Post to the server
$.ajax({
type: 'POST',
url: $("form.edit_item").attr("action"),
data: $("form.edit_item").serialize(),
success: function(e) {
}
});
$(".edit_item")
.bind('ajax:loading', function() {
alert('go');
})
.bind('ajax:success', function(data, status, xhr) {
alert('going');
})
});
表格上:
<form accept-charset="UTF-8" action="/xxxxx/18" class="edit_item" id="edit_item_31" method="post"><div
虽然表单发布工作正常,但 ajax 绑定不起作用。接下来我可以尝试什么?
$.ajax
选项中,添加 beforeSend
处理程序:
$.ajax({
type: 'POST',
url: $("form.edit_item").attr("action"),
data: $("form.edit_item").serialize(),
beforeSend: function() {
alert('go');
},
success: function(e) {
alert('going');
}
});
ajaxSend
和 ajaxSuccess
,如下所示:
$(".edit_item").bind({
ajaxSend: function() {
alert('go');
},
ajaxSuccess: function() {
alert('going');
}
});
这些火每个请求是为了您希望在批次开始/完成时发出警报,请将
ajaxSend
替换为ajaxStart
,将ajaxSuccess
替换为ajaxStop
。