Reputation: 11
I just try with Apache Cordova and normal jQuery to make an Ajax-Request. I have this code so far:
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
$(function () {
var datastring = "test";
$.ajax({
type: "POST",
url: "serverfiles/app-db-connection.php",
data: dataString,
success: function (data) {
$('#result').html(data);
alert("test");
}
});
$('#result').html("test");
});
};
the .php file is local and works, if I call it through the browser. Also the ajax-Part works fine in other normal webprojects.
So, what should I care about, then useing cordova. There have to be some issues with cordova. Even the test-alert isn't working.
A little hints how normal Ajax-requests work with cordova would help me a lot.
Normal Jquery-Code is working fine on the test-machines.
Upvotes: 0
Views: 1083
Reputation: 11
Ok. just solve the problem. 2 mistakes done: first: Var datastring and "dataString" were not written equal. second: it is not allowed to use in url-property a relative file-path. This because the file will not compiled by the app it self... it has to be an absolute path: http://blabla.com ... not ir works fine.
Upvotes: 1