2014-11-04 108 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