我正在嘗試修復我爲志願者組織的網站。
我試圖從角1.3.16更新到1.6.4角,但我發現了一個錯誤,指出消息:
TypeError: $http(...).success is not a function at b.$scope.init (angular-custom.js:107)
,這似乎是從導致它的代碼是什麼我可以通過調試它與.success和.error功能角custom.js文件告訴:
$scope.init = function(){
$http({
method: 'post',
url: url,
data: $.param({ 'type' : 'getUsers' }),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).
success(function(data, status, headers, config) {
if(data.success && !angular.isUndefined(data.data)){
$scope.post.users = data.data;
}else{
$scope.messageFailure(data.message);
}
}).
error(function(data, status, headers, config) {
//$scope.messageFailure(data.message);
});
};
我也把文件了在plunker The 1.3.16 files at Plunker下
我認爲它可能是.success和.error結果,但我不知道如何解決它的Angular。
我是一個自學成才的編碼員,所以任何幫助都會很棒,所以我可以組建並運行這個團隊。
在此先感謝您的任何建議。 杆
是的,'.success','.error'都很久以前就被棄用了,並在1.6版本中完全刪除。一些相關閱讀:http://www.codelord.net/2015/05/25/dont-use-%24https-success/ – CollinD
將其更改爲'.then(function(response){var data = response.data;。 ..' – Phil
感謝您的提示,我想我需要去花時間學習Angular –