Will jQuery .load() Work On PhoneGap?

后端 未结 2 1153
走了就别回头了
走了就别回头了 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);
        });
    });
    

提交回复
热议问题