Will jQuery .load() Work On PhoneGap?

后端 未结 2 1152
走了就别回头了
走了就别回头了 2020-12-19 23:26

I know that the jQuery .load() function has a \"problem\": You can\'t retrieve pages that are outside of the current domain, because of the Same Origin Policy, but I remembe

相关标签:
2条回答
  • 2020-12-19 23:58

    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);
        });
    });
    
    0 讨论(0)
  • 2020-12-20 00:15

    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).

    0 讨论(0)
提交回复
热议问题