我在ajax load()之后启动一个函数,但是函数I贴心地调用了一个不起作用的函数。如何在load()
之后启动ajaxstuff()
?ajax load()后的调用函数()
function ajaxstuff(data) {
$.ajax({
type: "POST",
url: "do-it.php",
data: {data},
success: function() {
console.log('I got this far'); // this doesn't work/isn't called
}
});
}
function doit() {
$('form').submit(function(e) {
e.preventDefault();
var formData = new FormData(this);
console.log('I got this far'); // this works
ajaxstuff(formData);
}
}
$('.popup-loader').click(function() {
$(this).append('<div class="popup"></div>');
$('.popup').load('popup.php', function() {
doit(); // this works
}
});
在ajaxstuff方法,我只看到了成功的回调。尝试添加 错误:函数(xhr,textStatus,errorThrown){ }以查看是否收到任何错误。 – Vim 2015-03-30 21:07:27
另外,我看到你正在发送FormData到ajax文章。设置,数据:数据, processData:false。 – Vim 2015-03-30 21:20:03
也许开始阅读文档http://api.jquery.com/jquery.ajax/ 有没有与Ajax“负载”的情况下,你有成功,失败,总是 – iamwhitebox 2015-03-30 22:00:53