【问题标题】:How to test JQuery fail callback?如何测试 JQuery 失败回调?
【发布时间】:2015-04-24 08:24:04
【问题描述】:

这是jquery函数:

$.get("/url", function(){

   //success
}).fail(function(){
  //fail     <---- how to make code go in there.
});

问题是如何让程序进入.fail块,我使用.Net MVC,但是在Controller中设置断点不会触发超时异常然后导致失败回调。

不知道人们如何测试这个。

我应该开始研究一些工具吗?

【问题讨论】:

标签: javascript jquery


【解决方案1】:

把它放在你的控制器方法中:

return new HttpStatusCodeResult(HttpStatusCode.NotFound);

【讨论】:

【解决方案2】:

使用无效的端点 URL。你应该得到 404 - not found http status code 错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    相关资源
    最近更新 更多