我有一个$http.post()用于进行Web服务调用的Angularjs应用程序.它调用的方法有一个void返回类型,它生成一个204(无内容)响应代码.这将进入.then()回调中定义的错误函数,并在日志中打印"找不到元素".
如果我从方法返回任何内容,它将返回正常的200响应代码.
为什么成功代码会触发错误功能?
所要求的代码:
function myFn(inputData) {
var d = { data: inputData };
$http.post("../api/my/serverFn", d)
.then(
function(response) {
$rootScope.AddMsg("Success");
},
function(response) {
// The 204 response goes here.
$rootScope.AddMsg("Error");
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3508 次 |
| 最近记录: |