轨道4 - 阿贾克斯:成功没有被触发 [英] Rails 4 - ajax:success isn't being triggered
本文介绍了轨道4 - 阿贾克斯:成功没有被触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过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');
});
这篇关于轨道4 - 阿贾克斯:成功没有被触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文