有没有办法在此 ajax 调用中使用 setTimeout。这是我的代码:
jQuery.ajax({
type : "POST",
url : dir+"all/money/myFile.php",
data : "page="+data.replace(/\&/g, '^'),
success : function(msg) {
var info = jQuery('.product_overview #allinfo').html();
var url = '<a href="http://www.mySite.com/openMe/letmeview.php?preview='+msg+'.html" target="_blank" class="check_link_preview" rel="'+msg+'.html">Check Preview</a>'; jQuery('.option_additional').next().find('textarea:first').text(info+url);
},
complete: function() {
jQuery('.add-to-cart button.btn-cart').delay(500).trigger('click');
}
});
我想在这个 ajax 被触发之前做一些事情,这就是为什么我会使用 setTimeout 或其他会延迟这个 Action 的东西。
我该怎么做?
提前致谢:)
最佳答案
之前没有使用 jquery 和 setTimeout 但尝试
var t = window.setTimeout(function, delay);
将上面代码中的函数替换为您的 jquery 函数。
关于javascript - setTimeout jquery 中的 ajax 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6978556/