我通过AJAX提交表单。我可以在Chrome浏览器的网络面板,这是succesfful返回一些JSON看看。然而,阿贾克斯:成功事件永远不会被解雇。为什么呢?
//不行的,尽管很多成功的网络小组研究。
$('#uploadDataForm')上(AJAX:成功,函数(){
的console.log('文件上传!');
});
// 作品。
$('#uploadDataForm')上(。阿贾克斯:发送,函数(){
的console.log('文件发送!');
的console.log('是的');
});
解决方案如果您使用小于1.7尝试
$(#uploadDataForm)绑定(AJAX:成功,函数(){
的console.log('文件发送!');
的console.log('是的');
});
否则,检查你得到一个200响应不是304或某事
或尝试使用全局Ajax响应 AJAX .ajaxSuccess()
$(文件)。在(AJAX:成功,函数(){
的console.log('文件发送!');
的console.log('是的');
});
I submit a form via ajax. I can see in the network panel of Chrome that it was succesfful and returned some JSON. However, the "ajax:success" event is never being fired. Why?
// Does not work, despite getting success in the Network Panel.
$('#uploadDataForm').on("ajax:success", function(){
console.log('file uploaded!');
});
// Works.
$('#uploadDataForm').on("ajax:send", function(){
console.log('file sent!');
console.log('yep');
});
解决方案
if your using less than 1.7 Try
$("#uploadDataForm").bind("ajax:success", function() {
console.log('file sent!');
console.log('yep');
});
Otherwise check you are getting a 200 response not 304 or something
or try using the global ajax response ajax .ajaxSuccess()
$(document).on("ajax:success", function() {
console.log('file sent!');
console.log('yep');
});