我在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