Will jQuery .load() Work On PhoneGap?

随声附和 提交于 2019-11-29 12:20:24
Jasper

You can use .load() or $.ajax() in PhoneGap applications. Most of my experience is with getting information from the same domain under which the app. is packaged. For example:

App. package identifier:

com.my-domain.my-app

Website domain for ajax calls:

www.my-domain.com


I just did a simple test in an iPhone emulator (via Xcode) and I was able to get the contents of a personal web domain as well as http://www.google.com/. Test was as follows:

$(document).ready(function () {
    $.get('http://www.google.com/', function (data) {
        alert(data);
    });
});
fxsam

I tried doing this, testing on the ipad simulator and it didnt work for me, I kept getting cross-domain ajax errors (i.e. permission errors).

I eventually found that I needed to Navigate to [projectName] -> Support Files -> phonegap.plist Under External Hosts add a new string with the value * Or add your exact domain

(From this link thanks to Dror 'Yitzhakov).

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