Phonegap + JQM: problems with local files on android

不问归期 提交于 2019-12-25 08:05:15

问题


I know this is common question, but I having a hard time understanding my results based on the various answers I have seen.

I have an phonegap + jquery mobile application that is using several local html files. The hierarchy looks like this

index.html
  |
  --- A.html  (uses getJSON() to server to get list)
  |     |
  |     --- A1.html  (uses getJSON() to server to get details)
  |
  --- B.html  (uses getJSON() to server to get list)
        |
        --- B1.html    (uses getJSON() to server to get details)

html and js assets are local. I am using jquery mobile.

Everything works fine on blackberry. On android, index.html, A.html, and B.html work fine. When trying to access the details views A1 and B1, I get "Error Loading Page".

I can't understand why A and B work, but A1 and B1 don't.

Although not sure why this would make a difference, from another thread I found a suggestion to add

android:configChanges="orientation|keyboardHidden"

to the activity in the manifest. This didn't change anything.

In case it is jquery related, I tried adding the following:

$( document ).bind( "mobileinit", function() {
    // Make your jQuery Mobile framework configuration changes here!
    $.mobile.allowCrossDomainPages = true;
    $.support.cors = true;
});

Still no love. Any ideas on how to fix or debug this?

Thanks, Aaron


回答1:


"Error Loading Page" means that jQuery Mobile could not find the document, which probably means that you are using relaitve URLs and they are getting messed up by the base-url. Try using absolute URLs.




回答2:


This problem is related to a webview bug that causes an error when passing data in the URL.

http://code.google.com/p/android/issues/detail?id=17535

The URL from A to A1 looks like A1.html?id=1 where the ?id=1 is causing the problem.

Cheers.



来源:https://stackoverflow.com/questions/9418818/phonegap-jqm-problems-with-local-files-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!