我是新来的英特尔XDK和jQuery Mobile的。 我知道,我想用我的应用程序数据库,以便去了有关使一个简单的页面,查询我的XAMPP数据库。 基本页面如下:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).on("tap","#name1",(function(e){
e.preventDefault(); // prevent the default action of the click
var vname = $("#name").val();
$.post("test.php", {name:vname}, function(response, status) { // POST instead of GET
// never use alert() for troubleshooting
// output for AJAX must be in the callback for the AJAX function
//console.log("recieved data-------*\n\nResponse : " + response +"\n\nStatus : " + status);
$('#table').html(response); // put response in div
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>The tap Event</h1>
</div>
<div data-role="main" class="ui-content">
<form method="post">
<select name="name">
<option value="Gammaplex">Gammaplex</option>
<option value="Specifics">Specifics</option>
<option value="Vigam">Vigam</option>
</select>
<button id="name1" type="submit">GO</button></form>
</div>
<div id="table"></div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
页面布局是直客W3C的学校。 林上dtabase运行查询是一个已知的脚本,在PHP应用程序,我有工作。 我将它的完整性:test.php的
<?php
include 'config.php';
$batchtype2 =($_POST['name']);
$batchtype2 = mysqli_real_escape_string($con,$batchtype2);
$sql = "SELECT * FROM script WHERE scriptname ='".$batchtype2."' ";
$result = mysqli_query($con,$sql);
$count=mysqli_num_rows($result);
if($count==0 ){
echo "</br></br></br></br></br></br></br><p> No Matching results found</p>";
}else{
while($row = mysqli_fetch_array($result)) {
echo " <form id='addgo' method='post'><label>Batch Number :</label><input id='gambana' name='gambana'>";
echo " <label>Planned Start Time : </label>"
. "<p><label>Hours /</label><label style='margin-left:2%;'>Mins</label></p><select id='pbstarti' name='pbstarti'>"
. "<option value='00'>00</option>"
. "<option value='01'>01</option>"
. "<option value='02'>02</option>"
. "<option value='03'>03</option>"
. "<option value='04'>04</option>"
. "<option value='05'>05</option>"
. "<option value='06'>06</option>"
. "<option value='07'>07</option>"
. "<option value='08'>08</option>"
. "<option value='09'>09</option>"
. "<option value='10'>10</option>"
. "<option value='11'>11</option>"
. "<option value='12'>12</option>"
. "<option value='13'>13</option>"
. "<option value='14'>14</option>"
. "<option value='15'>15</option>"
. "<option value='16'>16</option>"
. "<option value='17'>17</option>"
. "<option value='18'>18</option>"
. "<option value='19'>19</option>"
. "<option value='20'>20</option>"
. "<option value='21'>21</option>"
. "<option value='22'>22</option>"
. "<option value='23'>23</option>"
. "</select><select id='endtime' style='margin-left:2%;' name='endtime'>"
. "<option value='00'>00</option>"
. "<option value='05'>05</option>"
. "<option value='10'>10</option>"
. "<option value='15'>15</option>"
. "<option value='20'>20</option>"
. "<option value='25'>25</option>"
. "<option value='30'>30</option>"
. "<option value='35'>35</option>"
. "<option value='40'>40</option>"
. "<option value='45'>45</option>"
. "<option value='50'>50</option>"
. "<option value='55'>55</option>"
. "</select>";
echo " <label> Planned Start Date:</label> <input name='datepicker1' id='datepicker1' readonly='readonly'>";
echo " <input id='scriptp' name='scriptp' type ='hidden' value='0'>";
echo " <input id='batchtype' name='batchtype' type ='hidden' value='".$row['scriptname']."'>";
echo "<input id='scripthours' name = 'scripthours'; type='hidden' value='".$row['scripthours']."'>";
echo "<input id='formulation' name = 'formulation'; type='hidden' value='".$row['formulation']."'>";
echo " <input id='adddate' type='submit' value='Add ".$row['scriptname']." batch' class='btn btn-primary'></form>";
echo " ";
}
}
mysqli_close($con);
?>
当我运行该文件,并在控制台登录它,我得到一个无法找到资源错误。 对于我的test.php的文件。
我对项目文件的结构是:
WWW(顶层)
的index.html ---- PHP文件夹(第二级别)
的config.php ----- test.php的(第三级)
我试图/斜线盈绝对URL,但没有成功。 然后我开始认为它可能是被错误地写在JQM。
该项目被放置在我的XAMPP的htdocs文件夹。
有没有将资源添加到XDK和纹波时遵循的方法?
对于任何非常感谢帮助收到。
最后,这里是我的配置文件,以防万一:
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test3"; // Database name
// Connect to server and select databse.
$con = mysqli_connect("$host", "$username", "$password")or die("cannot connect");
mysqli_select_db($con,"$db_name")or die("cannot select DB");