开发者

getJSON returning null phonegap(android)

i am developing phone-gap app in android. In app I am calling a servlet returning JSON. Under app code I am calling following method through javascript in index.html

JQuery.getJSON(servleturl,function(data){alert(data)});

When running in emulator the alert is 开发者_如何学Pythongetting displayed, but data is always null. However if i launch the index.html (main application file in phonegap) from browser, I am able to get Json.

same thing happens even if I use $ajax. please help me and let me know what I am doing wrong.


A little bit later, but I had the same problem today, and I've solved it, so if you didn't sort this problem this would help.

So, the problem is not in JSON or in the phonegap, but it's in the AndroidManifest.xml file.

You should have a tag like this:

    <uses-permission android:name="android.permission.INTERNET" />

this should allow your application to work with Internet. Without this connection to Internet from your application is forbidden. That tag need to be placed right after the start tag.

Check Phonegap sample manifest for full list of possible permissions.

hope this will help to someone.


I fixed up (read made the changes to get working under a newer version of node.js) a little tool called ibug that John Boxall wrote that I found useful for debugging on the phone (since there is no real way to do it except debug.log and looking at XCodes console window. Its basically a stripped down firebug lite, and its hosted on github as ibug. Hopefully it will help you figure out why things aren't working.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜