my problem is:
When I call json using the following code
var url="http://localhost:9000/json";
$.getJSON(url,
function(data){
alert(data['yay']);
});
It works PERFECT, but, my localhost IP is 10.0.0.145, and when I replace localhost with the IP address, it no longer works
var url="http://10.0.0.145:9000/json";
$.getJSON(url,
function(data){
alert(data['yay']);
});
You are violating the same origin policy. If you control the destination site, you should either consider using a JSONP style of call or enable the cross domain option (crossDomain
) on your site and in your AJAX call.
Your browser won't make the call, by default, if you're violating same origin. You'll know that by watching your HTTP traffic using Fiddler, FireBug or Chrome Tools. You won't see your request even executed. If that's the case, then take one of the approaches above.
I hope this helps. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With