Issue
I am developing a cross-platform application with phonegap framework. I tried most of the command for contacting the server into the browser (phonegap run browser) and they worked fine. Then i tried to lunch the application in the genymotion emulator (phonegap run android) but it seem that the call to the server (made with ajax) always end in error but it is the same code that worked on the browser
//LOGIN
function fLogin(){
$("#bacheca").hide();
console.log("prova jquery");
$("#log").click(function(){
let nome = $("#username").val();
let pass = $("#password").val();
console.log("Clicked login with values: "+nome+" "+pass);
$.ajax({
method: "post",
url: "..myserver..",
data: {username: nome, password: pass},
success: function(result){
console.log("found: "+result);
sessione = result;
showHome();
localStorage.setItem("sessione",sessione);
localStorage.setItem("myname",nome);
myname = localStorage.getItem("myname");
},
error: function(){
console.log("error");
}
});
})
}
Solution
Obviously you dont have internet access?
Add the whitelist plugin
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
You might need to add this meta tag on the head
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline'; media-src *">
And add this two lines to the config.xml
<allow-navigation href="http://*/*" />
<allow-intent href="https://*/*" />
Answered By - proofzy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.