Reputation: 2763
I was trying to make AJAX request to some website in the localhost within phonegap but it's not working and I got just failure and i tried a lot of ways to it but nothing happened
and when I try doing it with some local file for the phonegap it works 100%
I have read that its cross domain problem so I tried jSONP and nothing it could be a problem from the emulator or phonegap or maybe there is a specific way to do it
Please Help
this is one of the solutions I tried
$.ajax({
url: "http://127.0.0.1/test/index.php",
type: "POST",
dataType: "json",
success: function(msg){
alert(msg);
}
}
)
I tried emulating it using DW 5.5 and its worked normally how can i fix this on eclipse
Upvotes: 2
Views: 2374
Reputation: 397
yes palcoder.... I have this issue too... it has taken a whole day to find the problem.
Its the eclipse who is the culprit... After so many times checking with hit and trial I came to know
that running on localmachine will not allow the ajax jsonp process to execute. You should use a
different domain... and it works like a charm...
Hope some one doesn't waste time on localhost just like me. :)
Upvotes: 0
Reputation: 29562
You need to change url: "http://127.0.0.1 to the IP address of the PC where the php server is running. On MacOS and Linux, the ifconfig command will tell you the IP address. Get that IP address and replace the //127.0.0.1 in your source.
Upvotes: 5