-1

我正在像这样使用 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; 
  }

}

我看过教程证明这是可能的,但我无法让它工作。有人可以帮我吗?谢谢!

4

1 回答 1

3

改变

OnBegin = "test()"

OnBegin = "return test()"
于 2014-11-05T00:50:31.227 回答