I’m running a sample jQueryMobile app that runs in PhoneGap. The problem is that it doesn’t run the getJSON callback to retrieve data, shown below:
$( function()
{
$('#searchButton').click(function()
{
alert("search clicked"); <== this alert works
var url = "http://api.alternativeto.net/software/firefox?callback=?";
$.getJSON(url, function(data) <== this should be, but isn't being called
{
alert("function data called"); <== so this alert doesn't show.
} // end function (data)
); // end getJSON
alert("getJSON call completed"); <== and this alert works
} // end search click.function()
); // end $(
The “search clicked” and “getJSON call completed” alerts both work. The returned JSON I get from entering the url in a browser is valid.
The test code is from this URL:
http://wiki.phonegap.com/w/page/36868306/UI%20Development%20using%20jQueryMobile
Is there anything else I can check?
I don’t believe you need the
?callback=?in yoururlsince you can make cross-domain requests from an app.I have had success with:
..which logged the HTML of Google’s homepage.