angular $http 官方实例说明
General usage The // 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. }); The response object has these properties:
A response status code between 200 and 299 is considered a success status and will result in the success callback being called. Any response status code outside of that range is considered an error status and will result in the error callback being called. Also,status codes less than -1 are normalized to zero. -1 usually means the request was aborted,e.g. using a Shortcut methodsShortcut methods are also available. All shortcut methods require passing in the URL,and request data must be passed in for POST/PUT requests. An optional config can be passed as the last argument. $http.get('/someUrl', config).then(successCallback, errorCallback); $http.post( data, errorCallback); Complete list of shortcut methods:
原文地址:https://docs.angularjs.org/api/ng/service/$http
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |