I try to use Angularjs http service to call my PHP API. Everything working fine in Browser. But, when I test it on my Android Phone, it will not work.
My Issue:
In Android PhoneGap Application, Whenever I trigger the Angularjs http service it will always trigger the function (error) even when the Mobile is connected with Internet.
I have try look this but their solution aren't working:
- Angular $http.get() does not work in Phonegap DevApp
- Cordova 5.3.1 Android app can't access the internet
I also have ensure the Phonegap config.xml has allowed Internet Permission Access with:
<access allows-arbitrary-loads-in-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
However it is still not Working.
My Question:
- Is Angularjs http service is not able to work on PhoneGap Mobile Application but only Web Browser?
- Aside from
config.xml, is there any other configuration have to be made to allow PhoneGap Mobile Application to access the Internet?
Angularjs code:
$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
$http({
method: 'POST',
data: {
'email' : $scope.email,
'password' : $scope.password,
},
url: 'https://unsurfaced-cross.000webhostapp.com/PGLogin.php'
}).then(function (response){
$scope.users = response.data;
if(response.data[0]=="LOGIN"){
alert("Successful Login");
$window.location.href = './homepage.html';
}else{
alert("Login Failed. Incorrect Email or Password.");
}
},function (error){
alert("Please ensure You are connected to Internet.");
});