gpt4 book ai didi

javascript - Angularjs - $http 成功与那时

转载 作者:行者123 更新时间:2023-11-29 16:07:07 24 4
gpt4 key购买 nike

我想问一下这个方法的区别我关心的是 .then 和 .success、function 以及 .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.
});

最佳答案

.then().sucess() 都是指 promise 它异步运行并等待响应,如果它满足您的请求然后 resolve 否则拒绝它。

.success.error 已弃用您可以在文档中找到更多详细信息

关于javascript - Angularjs - $http 成功与那时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38627623/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com