簡體   English   中英

如何使用Jquery.Unobtrusive.Ajax取消Ajax請求?

[英]How to cancel ajax request using Jquery.Unobtrusive.Ajax?

我正在像這樣使用Ajax.ActionLink

@Ajax.ActionLink("link text", "action", new AjaxOptions(){ OnBegin = "test()" })

我希望能夠根據我在javascript中的test()函數的結果來取消鏈接的ajax調用,就像這樣

function test(){

  if(condition){
    //execute the ajax request 
    return true; 
  }else
  {
    //cancel the ajax request
    return false; 
  }

}

我看過一些教程證明這是有可能的,但是我莫名其妙地使它無法工作,有人可以幫我嗎? 謝謝!

更改

OnBegin = "test()"

OnBegin = "return test()"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM