Phonegap / Cordova: jQuery message for external server not working

I am trying to publish some data to an external resource in the Phonegap / Cordova 3.3.0 application on iOS 7. When I call the jQuery method $.post, it does not send any data, it throws an exception in the remote debugger:

Failed to load resource: file:///var/mobile/Applications/49A5E640-BD77-46EA-A5E5-CCE19ACF6ED2/tracker.app/www/%5Bobject%20Object%5D
The requested URL was not found on this server.

This is the code I'm using:

    $.post({
      url: 'http://www.my-server.com/json.php',
      data: JSON.stringify({ "lat": event.coords.latitude, "lng": event.coords.longitude }),
      dataType: 'application/json'
      crossDomain: true,
      success: function(data){
        console.log("Success: " + data);
      },
      error: function(data) {
        console.log("Error: " + data);
      }
    });

Are there any cross domain related things? Or how can I fix this problem?

+3
source share
1 answer

Try adding the following line of code to the json.php file and see what happens:

header("Access-Control-Allow-Origin: *");
0
source

All Articles