jquery.load()不工作phonegap 3.0.0 [英] jquery.load() is not working on phonegap 3.0.0

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

问题描述

我是新手开发一个phonegap应用程序。我已经检查过这些帖子: jquery.load()无法处理phonegap 如何在phonegap中使用jquery load()加载网页 jquery .load()函数在phonegap下不起作用 ...但似乎没有什么帮助。



我正在开发一个应用程序在phonegap与jquery和外部设备运行它而不是一个模拟器。我有2个html: breakfast.html tab.html



我的文件夹结构是:

 ▸merges / 
▸平台/
▸插件/
▾www /
▸css /
▸img /
▸js /
▸res /
▸spec /
▾static_pages /
▾布局/
tab.html
breakfast.html
config.xml
icon.png
index.html
spec.html

我的 Breakfast.html

  <!DOCTYPE html> 
< html>
< head>
< meta charset =utf-8/>
< meta name =format-detectioncontent =telephone = no/>
< meta name =viewportcontent =user-scalable = no,initial-scale = 1,maximum scale = 1,minimum-scale = 1,width = device-width,height = device-height, target-densitydpi = device-dpi/>
< link rel =stylesheettype =text / csshref =../ css / bootstrap.min.css/>
< link rel =stylesheettype =text / csshref =../ css / custom_forms.css/>
< title> Hello World< / title>
< script type =text / javascriptsrc =../ phonegap.js>< / script>
< script type =text / javascriptsrc =../ js / index.js>< / script>
< script type =text / javascriptsrc =../ js / bootstrap.min.js>< / script>
< script type =text / javascriptsrc =../ js / jquery-1.10.2.min.js>< / script>
< script type =text / javascript>
app.initialize();
< / script>
< / head>
< body>
< header class =navbar navbar-fixed-top>
XXXXXXX
< / header>
< div id =testing>< / div>
< script> $(#testing).load(layouts / tab.html #test);< / script&
< footer class =navbarid =footer_bottom>
XXXXXXXX
< / footer>
< / body>
< / html>

我的 tab.html 是:

 < div id =teststyle =width:100%; heigt:90px; background:black; color:white;& 
TESTING JQUERY
< / div>

关于官方api.jquery.com/load页面,我要做的是插入一部分具有id的html文件我必须做下一步:

 <!doctype html> 
< html lang =en>
< head>
< meta charset =utf-8>
< title> load demo< / title>
< style>
body {
font-size:12px;
font-family:Arial;
}
< / style>
< script src =http://code.jquery.com/jquery-1.9.1.js>< / script>
< / head>
< body>

< b>页脚导航:< / b>
< ol id =result>< / ol>

< script>
$(#result).load(ajax / test.html #container);
< / script>

< / body>
< / html>

我不知道我做错了什么。



之前有人遇到过这个问题,明白为什么吗?



提前感谢。



更新:



对不起,我正在为Android开发,设备是LG optimus 2X与android 4.2.2


< divization =h2_lin>解决方案

感谢Pawel(和官方 http://docs.phonegap.com/en/3.0.0/guide_appdev_whitelist_index.md.html#Domain%20Whitelist%20Guide )我可以找出解决方案。正如他精辟地建议,问题是与我的phonegap应用程序的白名单域配置。要解决此问题,您必须修改 your_app / www / config.xml 文件,并尝试查找:

 < access origin =http://127.0.0.1*/> 

您必须将其更改为:

 < access origin =*/> 

就是这样。



感谢Pawel向我展示方式)


I'm newbie developing a phonegap app. I already checked those posts: jquery.load() not working on phonegap and how to load pages using jquery load() in phonegap and jquery .load() function does not work under phonegap... but nothing seems to help.

I'm developing an app in phonegap with jquery and an external device to run it instead of an emulator. I have 2 html: breakfast.html and tab.html

My folder structure is:

▸ merges/               
▸ platforms/            
▸ plugins/              
▾ www/                  
  ▸ css/                
  ▸ img/                
  ▸ js/                 
  ▸ res/                
  ▸ spec/               
  ▾ static_pages/       
    ▾ layouts/          
        tab.html        
      breakfast.html    
    config.xml          
    icon.png            
    index.html          
    spec.html

My Breakfast.html is

<!DOCTYPE html>                                                                                 
<html>                                                                                          
    <head>                                                                                      
        <meta charset="utf-8" />                                                                
        <meta name="format-detection" content="telephone=no" />                                 
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />          
        <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" />               
        <link rel="stylesheet" type="text/css" href="../css/custom_forms.css" />                
        <title>Hello World</title>                                                              
        <script type="text/javascript" src="../phonegap.js"></script>                           
        <script type="text/javascript" src="../js/index.js"></script>                           
        <script type="text/javascript" src="../js/bootstrap.min.js"></script>                   
        <script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>               
        <script type="text/javascript">                                                         
          app.initialize();                                                                     
        </script>                                                                                            
    </head>                                                                                     
     <body>                                                                                      
       <header class="navbar navbar-fixed-top">
         XXXXXXX                                                                       
       </header>                                                                                 
         <div id="testing"></div>                                                                
         <script>$( "#testing" ).load( "layouts/tab.html #test" );</script>       
       <footer class="navbar" id="footer_bottom">                                                
         XXXXXXXX                                                              
       </footer>                                                                                 
     </body>    
</html>

My tab.html is:

<div id="test" style="width:100%;heigt:90px;background:black;color:white;">
  TESTING JQUERY                                                           
</div>                                                                     

Regarding to official api.jquery.com/load page what I have to do to insert a part of an html file with an id I have to do next:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>load demo</title>
  <style>
  body {
    font-size: 12px;
    font-family: Arial;
  }
  </style>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>

<b>Footer navigation:</b>
<ol id="result"></ol>

<script>
$( "#result" ).load( "ajax/test.html #container" );
</script>

</body>
</html>

I don't know what I'm doing wrong.

Does anyone faced this issue before and figure it out why?

Thanks in advance.

UPDATE:

Sorry, I'm developing for Android, and the device is a LG optimus 2X with android 4.2.2

解决方案

Thanks to Pawel (and the official http://docs.phonegap.com/en/3.0.0/guide_appdev_whitelist_index.md.html#Domain%20Whitelist%20Guide) I could figure out the solution. As he brilliantly suggest, the problem was with the whitelist domain configuration of my phonegap application. To solve it you have to edit your your_app/www/config.xml file and try to locate:

<access origin="http://127.0.0.1*" />

You must change it to:

<access origin="*" />

That's it. Now it works.

Thanks Pawel to show me the way ;)

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

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