I'm fetching some data from remote server using AngularJS $http. It's working in browser but not in phonegap developer app. But, ajax is working. What could be the problem!!
Here is the code I'm using.
$http({
url: domain + "modulesinfo/list",
method: "GET",
//Added after some research // I'm testing on local server
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
})
.success(function(data){
$scope.modules = data.response;
$scope.$apply();
})
.error(function(){
navigator.notification.alert("You are damned", function(){
}, "Not working", "OK");
});
I tried adding header after some research, But that didn't work.
$http.jsonp(domain + "modulesinfo/list?callback=JSON_CALLBACK")
.success(function(data){
console.log(data);
$scope.modules = data.response;
})
.error(function(){
console.log(data);
});
This solved my problem. Hope it help others. Adding the callback=JSON_CALLBACK with the url is working in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With