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