我正在使用angular-phonegap-seed编写一个移动应用程序,我想知道使用$http是否有任何已知的问题。
我的控制器代码是在按下按钮时调用的。
$http.get('http://192.168.1.2:8000/request_token').success(function(data, status, headers, config){
$scope.token = 'sucess: ' + data + ' ' + status + ' ' + headers + ' ' + JSON.stringify(config);
}).error(function(data, status, headers, config){
$scope.token = 'error: ' + data + ' ' + status + ' ' + headers + ' ' + JSON.stringify(config);
});目前,服务器上的request_token只是一个带有虚拟令牌的文件。
服务器在控制台中确认收到请求,并返回200。然而,android上的phonegap应用程序会做出回应:
error: undefined undefined undefined {"transformrequest": [NULL], "transformresponse": [NULL], "method": "GET", "url": "http://server-ip:8000/request_token", "headers": {"accept": "application/json, text/plain, */*"}}我可以在phonegap中使用常规的$http.get()方法,还是必须使用phonegap api?
发布于 2013-08-02 18:38:13
在我的例子中,结果是我忘记了将我发送请求的域名列入白名单。
查看Domain Whitelist Guide,看看它是否有帮助。
https://stackoverflow.com/questions/17674529
复制相似问题