[英]AngularJS $http.get() always returns error?
為什么下面的代碼在沒有狀態的情況下運行錯誤回調? Firefox中的Web Developer報告狀態代碼200。
有什么辦法可以調試嗎?
<meta charset="utf8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script type="text/javascript">
function RoomListCtrl($scope, $http) {
$scope.getRooms = function() {
$http({method: 'GET', url: 'http://code.angularjs.org'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
alert('succes');
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
alert('error');
});
}
$scope.submit = function() {
this.getRooms();
}
}
</script>
<body ng-controller="RoomListCtrl"><form ng-submit="submit()">
<input type="text" value="" ng-model="search" name="search" >
</form></body>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.