我有一本 ibook,我正试图从我的服务器上的云数据库中拉回一个数据表。如果我将 main.html 文件放在我的服务器上并使用我的网络浏览器浏览它,它就像一个返回数据表的冠军,但是当我将此 html 作为我的 main.html 文件放在 Info.plist 中时它不会在 ibook 中显示表格。我错过了什么?
这是我的 html 文件,它位于本书页面上 ibook html 小部件的小部件中
<html>
<head>
<script type="text/javascript" src="http://myserver.com/ibook_widgets/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: 'post',
url: 'http://myserver.com/ibook_widgets/getdata.php?id=4',
data: 'json',
beforeSend: function() {
// before send the request, displays a "Loading..." messaj in the element where the server response will be placed
$('#resp').html('Loading...');
},
timeout: 10000, // sets timeout for the request (10 seconds)
error: function(xhr, status, error) { alert('Error: '+ xhr.status+ ' - '+ error); },
success: function(response) { $('#listhere').html(response); }
});
});
</script>
</head>
<body>
<div id="listhere" style="border: solid black 1px; background-color:red;">Replace this text with html table from php file</div>
</body>
</html>
这是我的服务器上的 php 文件
<?php
/*
* Following code will list all the products
*/
$dbhostname='myserver.com';
$dbusername='usr';
$dbpassword='pwd';
$dbname='mydatabase';
$con = mysql_connect($dbhostname,$dbusername,$dbpassword);
mysql_select_db($dbname, $con);
// check for post data
if (isset($_POST["id"]))
{
$inValue = $_POST['id'];
$sql = 'select id, btn_txt from mytable where parent_id = '.$inValue.' order by btn_txt';
$result = mysql_query($sql) or die(mysql_error());
if (!empty($result))
{
// check for empty result
if (mysql_num_rows($result) > 0)
{
$row = mysql_fetch_array($result);
$btntxt = $row['btn_txt'];
$result1 = mysql_query($sql) or die(mysql_error());
// check for empty result
if (!empty($result1))
{
// check for empty result
if (mysql_num_rows($result1) > 0)
{
// looping through all results
// products node
$tmpStr = "<table border='1'><tr><th>Tap A Row To See Details</th></tr>";
// show select box input_select_4
while($row1 = mysql_fetch_array($result1))
{
$tmpStr = $tmpStr . "<tr><th><a href=\"http://myserver.com/ibook_widgets/getdata.php?id=". $row1["id"] . "\" target=\"_self\">" . $row1["btn_txt"] . "</a></th></tr>";
}
$tmpStr = $tmpStr . "</table>";
echo $tmpStr;
// echoing JSON response
///echo json_encode($tmpStr);
mysql_close($con);
// echoing JSON response
////echo json_encode($response);
}
}
}
}
}
?>
我错过了什么?