将jQuery .load()工作在PhoneGap? [英] Will jQuery .load() Work On PhoneGap?

查看:137
本文介绍了将jQuery .load()工作在PhoneGap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 jQuery .load()函数有一个问题:您可以' t检索超出当前域的网页,因为同源政策,但我记得当我开发另一个程序,我可以做跨域AJAX没有问题,而在PhoneGap编译环境,但它会工作,而PhoneGap(像正常的AJAX)或它只会失败,因为政策?

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 remember when I was developing another program that I could do cross-domain AJAX without problems while on an PhoneGap compiled environment, but will it work while on PhoneGap(like normal AJAX) or it will just fail because of the policy?

推荐答案

您可以使用 .load() $。 ()。我的大部分经验是从同一个域下的应用程序获取信息。是包装。例如:

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:

应用程式。包标识符:


com.my-domain.my-app

com.my-domain.my-app

ajax通话的网站网域:

Website domain for ajax calls:


www.my-domain.com

www.my-domain.com






我只是在iPhone模拟器(通过Xcode)做了一个简单的测试,我能够得到一个个人网域以及 http://www.google.com/ 。测试如下:

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

这篇关于将jQuery .load()工作在PhoneGap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆