Reputation: 217
I have developed a sample app on Android using Phonegap.
When clicked on a button, an Ajax request is made to the server (http://192.168.0.199:8080/test.php).
The test.php just echoes hello world.
I am using Jquery 1.5 for making the Ajax call.
Here is the code for the Ajax call:
$.ajax({
url:"http://192.168.0.199:8080/test.php",
beforeSend: function(x) {
alert("The URL "+url);
},
type:'POST',
crossDomain: true,
success:function(data) {
alert(data);
},
error:function(XMLHttpRequest,textStatus, errorThrown) {
alert("Error status :"+textStatus);
alert("Error type :"+errorThrown);
alert("Error message :"+XMLHttpRequest.responseXML);
}
});
But, every time this function is called, it throws an error:
Error Type: No Transport
Error Message: undefined
Error Status: error
Note: I have added the INTERNET Permission in the Manifest file. I am using a G1 device running Android 1.6
Thanks in advance
Upvotes: 1
Views: 2291
Reputation: 11
As of jQuery 1.5 a new AJAX / XHR implementation is in use. And Android 1.5 / 1.6 doesn't say it supports CORS (crossdomain calling). So a way to 'fix' that is to inform jQuery it does support cors:
jQuery.support.cors = true;
I couldn't reproduce the problem on 2.1 and up. So I expect the XHR implementation from that version on does say it does support cors.
Upvotes: 1
Reputation: 630
Looks like you are trying to make an call to a client within a local network.
Try validating you have access to that local network.
Upvotes: 1