如何延缓默认动作? [英] how to delay default action?
本文介绍了如何延缓默认动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在jQuery的,我需要延缓锚的默认行为,因此,在此期间,AJAX POST请求可以完成自身。
in jquery, i need to delay the default behavior of anchors, so that in the meantime, ajax post request can complete itself.
preventDefault或。点击事件返回false,不会做,因为我还需要导航到这些页面。 window.location的HREF =显然失败了,因为一些锚没有href属性,而不是使用JavaScript。我不控制这些网页。
preventDefault or returning false in .click event wont do, as I still need to navigate to those pages. window.location = href obviously fails because some anchors do not have href attribute instead uses javascript. I do not control these pages.
推荐答案
您刚刚使用的 AJAX功能,jQuery的的本身
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
// do what you need to here
return true;
}
});
然后,它会等待,直到阿贾克斯移动到成功回调之前完成
Then it will wait until the Ajax has completed before moving on to the success callback
这篇关于如何延缓默认动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文