我在使用 get http 动词时遇到了一些问题,也许你可以帮助我。如果我不得不猜测,我会说标题很糟糕,但我什至不知道如何阅读我在 Firebug 上的响应。
额外:javascript 文件和来自服务器的响应。
控制器.js
"use strict"
angular.module('app.controller', [])
.config(function ($httpProvider) {
delete $httpProvider.defaults.headers.common['X-Requested-With'];
})
.controller('myCtrl', function ($scope, $http) {
$http.get("http://www.perdu.com/")
.success(function (data, status) {
console.log("Status ;" + status + "; \n" + data);
$scope.htmlResponse = data;
})
.error(function (data, status) {
console.log("connection to google:", status);
$scope.htmlResponse = status;
});
});
GET http://www.perdu.com/
200 OK 214ms
Headers
回复
Accept-Ranges bytes
Cache-Control max-age=0, no-cache
Content-Encoding gzip
Content-Length 163
Content-Type text/html
Date Fri, 11 Oct 2013 15:12:53 GMT
Proxy-Connection keep-alive
Server Apache
Vary Accept-Encoding
Via 1.0 serv320v.numenservices.fr:3128 (squid/2.6.STABLE21), 1.0
cevpx001.multipap.corp:3128 (squid/2.6.STABLE21)
X-Cache MISS from serv320v.numenservices.fr, MISS from cevpx001.multipap.corp
X-Cache-Lookup MISS from serv320v.numenservices.fr:3128, MISS from
cevpx001.multipap.corp:3128
X-Mod-Pagespeed 1.1.23.1-2169
Request
Accept application/json, text/plain, */*
Accept-Encoding gzip, deflate
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Host www.perdu.com
Origin http://localhost:8000
Referer http://localhost:8000/app/index.html
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0
connection to google: 0
编辑:$scope.htmlResponse = 0,但浏览器告诉我请求发送了 OK 状态。