如何延缓默认动作?动作

由网友(执念)分享简介:在jQuery的,我需要延缓锚的默认行为,因此,在此期间,AJAX POST请求可以完成自身。in jquery, i need to delay the default behavior of anchors, so that in the meantime, ajax post request can compl...

在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

阅读全文

相关推荐

最新文章