2014-11-04 106 views
-1

我使用Ajax.ActionLink这样如何使用Jquery.Unobtrusive.Ajax取消ajax请求?

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

我希望能够取消基于我的测试()的JavaScript函数的结果链接的Ajax调用,像这样

function test(){ 

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

} 

我见过的教程证明这是可能的,但我不知何故无法使它工作。可以有人帮助我吗?谢谢!

回答

2

变化

OnBegin = "test()" 

OnBegin = "return test()" 
+0

它的工作!谢谢\ o / – 2014-11-05 14:45:11