dtslobe4694 2013-12-18 16:12
浏览 55
已采纳

将php内容加载到Phonegap中

I am working with phonegap and dreamweaver to setup a small application but i am facing a problem as i am a new in phonegap.

I have an HTML5 file and my css file also the config.xml form my icon, splashscreen etc. Phonegap reads only the index.html and not the index.php file.

So i made a grab.php file to pull some data from my hosting. Localhost everything works great but when i am build the app it doesn't load the data...

Here is my html file and grab.php file.

<!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" />
<title>Celebrity.Com | Android App</title>
<link rel="stylesheet" type="text/css" href="mobile_css/style.css" media="all" />
<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>

<script type="text/javascript">
$(document).ready(function() {
    $(".loa").load("grab.php");
});
</script>

</head>

<body>

<div class="headerHolder"><div class="logo"></div></div>
<div style="width:100%; height:20px; float:left; margin-bottom:1px;"></div>

<div class="loa" style="width:100%; padding-bottom:5px;">

<div style="clear:both;"></div>
</div>

</body>
</html>

And grab.php

<?php
require "connectiondb.php";
$bann = mysql_query ("SELECT * FROM info ORDER BY a_name");
while($bannerl = mysql_fetch_assoc($bann)) {
echo '
<div class="articleHolder">
<div class="imageholder"><img src="'.$bannerl['a_image'].'" width="180" height="120"/></div>
<div class="controlz"><span style="float:left;">'.$bannerl['a_name'].'</span><img style="width:65px; height:65px; float:right;" src="images/details.png" width="65" height="65" border="0"></div>
</div>';
}
?>

I tried to upload the grab.php file to my server and load it from here but i think that the policy doesn't let me to run, load files from other servers.

  • 写回答

1条回答 默认 最新

  • dqh1992 2013-12-18 16:16
    关注

    You need to put your host in a whitelist (http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html)

    Then you have to specify in Phonegap configuration your domain:

    Then you can make ajax requests, but you have to specify the domain, so needs to be something like:

    <script type="text/javascript">
    $(document).ready(function() {
        $(".loa").load("http://yourdomain.com/grab.php");
    });
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号