我正在使用JQuery客户端进行Ajax调用。
var ajaxCalls = [];
ajaxCalls.push(executeOne());
ajaxCalls.push(executeTwo());
function executeOne() {
return $.ajax({
type: "POST",
async: true,
url: URL,
contentType: "application/json",
data: JSON.stringify(Params),
dataType: "json"
});
}
;
function executeTwo() {
return $.ajax({
type: "POST",
async: true,
url: URL,
contentType: "application/json",
data: JSON.stringify(ParamsTwo),
dataType: "json"
});
}
;
$.when.apply($, ajaxCalls).then(function () {
//DO something
}).fail(function () {
//Do something
}).always(function () {
});
在.net方面,我有一个简单的控制器,我抛出异常:
[HttpPost]
public HttpResponseMessage Results(ParamsModel data)
{
throw new Exception("Error");
}
问题:状态代码返回200而不是500.因此,fail
客户端块永远不会被执行。
请建议。