如何使用Jquery.Uno唐突.ajax取消ajax请求

How to cancel ajax request using Jquery.Unobtrusive.Ajax?

本文关键字:ajax 取消 请求 唐突 Uno 何使用 Jquery      更新时间:2023-09-26

我正在使用类似的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()"