There are several questions on stackoverflow saying cross domain ajax request etc will not work because of security reasons.
Some questions like this explain this. (Please let me know if I am wrong.)
Now here is the thing:
This is working perfectly fine:
$ (document).ready(function() {
$ .getJSON("http://search.twitter.com/search.json?q=test&callback=?", function(data) {
alert("test alert outside loop");
$ .each(data.results, function() {
alert("test alert inside loop");
});
});
});
But just replacing the url with my application wont work. In that case response code is 200, but no response. There is an hit on my application. I can see that in console.
$ (document).ready(function() {
$ .getJSON("http://192.168.1.2/cities.json?callback=?", function(data) {
alert("test alert outside loop");
$ .each(data.results, function() {
alert("test alert inside loop");
});
});
});
Like i am confused why this is not working.
*PS: I am developing very simple mobile app using phonegap so I need to make this call using javascript only. But the main thing for me is why twitter call is working but not mine. I also tried to remove protect_from_forgery from application controller in my rails app. But i don’t think that matters.*