Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs-$http成功vs then_Javascript_Angularjs_Api_Angular Promise_Angular Http - Fatal编程技术网

Javascript Angularjs-$http成功vs then

Javascript Angularjs-$http成功vs then,javascript,angularjs,api,angular-promise,angular-http,Javascript,Angularjs,Api,Angular Promise,Angular Http,我想问一下这种方法的区别 我关心的是。然后和。成功,功能和。错误之间的区别 谢谢 及 .then()和.suces()都是指承诺它异步运行并等待响应(如果它满足了您的请求),然后解决它,否则拒绝它 .success和.error不推荐使用。您可以找到有关文档的更多详细信息不要使用success和error,使用then和catch。.success和.error不推荐使用。请在此处查找承诺文档:可能重复的 // Simple GET request example: $http({ met

我想问一下这种方法的区别 我关心的是。然后和。成功,功能和。错误之间的区别 谢谢

.then()
.suces()
都是指承诺它异步运行并等待响应(如果它满足了您的请求),然后
解决它,否则
拒绝它


.success
.error
不推荐使用。您可以找到有关文档的更多详细信息

不要使用success和error,使用then和catch。
.success
.error
不推荐使用。请在此处查找承诺文档:可能重复的
// Simple GET request example:
$http({
   method: 'GET',
   url: '/someUrl'
}).then(function successCallback(response) {
   // this callback will be called asynchronously
   // when the response is available
}, function errorCallback(response) {
   // called asynchronously if an error occurs
   // or server returns response with an error status.
});
// Simple GET request example:
$http({
   method: 'GET',
   url: '/someUrl'
}).success(function successCallback(response) {
   // this callback will be called asynchronously
   // when the response is available
}).error( function(data) {
   // called asynchronously if an error occurs
   // or server returns response with an error status.
});