$ http是否适用于phonegap?

low*_*key 4 android http angularjs cordova

我正在使用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);
});
Run Code Online (Sandbox Code Playgroud)

目前,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, */*"}}
Run Code Online (Sandbox Code Playgroud)

我可以在phonegap中使用常规$ http.get()方法,还是必须使用phonegap api?

Jus*_*Lau 7

就我而言,事实证明我忘了将我发送请求的域名列入白名单.

查看域白名单指南,看看它是否有帮助.