[英]Jquery mobile getJSON works in browser but not in mobile device
我在Jquery mobile 1.4.5上有一個項目,其中我從本地JSON數據加載數據並將其解析為列表。 當我在firefox中對其進行測試時,它工作正常,列表已填充,一切正常,但是當我在cordova和android中對其進行編譯時,在移動設備上,JSON列表未填充。 我將data.json文件保留在www項目文件的根文件夾中。 可能是什么問題?
$.getJSON('data.json', function(data) {
var output="<ul>";
for (var i in data.sometext) {
output+="<li " +
"blah blah blah"
"</li>" ;
}
output+="</ul>";
document.getElementById("placeholder").innerHTML=output;
});
在我的科爾多瓦的配置文件中,我有:
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" version="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<preference name="orientation" value="portrait" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
我知道這很舊,這為我解決了這個問題:
如果您使用Prepros或其他Web開發工具,則可能忘記了將json文件上傳到FTP。 然后,它將在localhost上正常工作,但在url中無法正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.