【发布时间】:2009-11-13 07:43:59
【问题描述】:
我是新来的。我只是创建一个可以从 mysql 数据库读取数据的代码。 但是当我在数据库中添加新数据时,我的 php 页面无法自动更新。 我希望页面可以在按下 f5 按钮并刷新的情况下自动更新。 谁能帮我解决这个问题?
有什么错误吗??
<script type="text/javascript">
function List(){
var ajaxRequest;
var selectedProduct = "";
var product = document.getElementById('product');
var output ="";
var k = 0;
// var name = new Array;
// var model = new Array;
var unitprice = new Array;
var queryString = new Array;
queryString = "&name=" + txtname + "&model=" + txtmodel + ;
ajaxRequest.open("GET", $productPrice + queryString, true);
ajaxRequest.send(null);
ajaxRequest.open("GET", $productPrice + queryString, true);
ajaxRequest.send(null);
<?php foreach ($productPrices as $price): ?>
name[k] = "<?php echo $price['Product']['txtname']; ?>";
model[k] = "<?php echo $price['Product']['txtmodel']; ?>";
k++;
<?php endforeach; ?>
k=0;
for (var i = 0; i < product.length; i++) {
k = product.options[i].value;
if (product.options[i].selected) {
output += '<tr>'+
'<td style="border-right: 0px; width:270px; text-align:center" id="ProductProduct'+k+'" name="data[Product][Product]['+k+']">'+name[i]+'</td>'+
'<td style="border-right: 0px; width:100px; text-align:left" id="ProductProduct'+k+'" name="data[Product][Product]['+k+']">'+model[i]+'</td>'+
'</tr>';
}
}
output = '<table style="width:500px; border: 0px;">'+output+'</table>';
document.getElementById('productTable').innerHTML = output;
}
</script>
【问题讨论】:
-
一个 javascriptlibrary 可能会使这项工作更容易
-
是的,虽然使用的是你所拥有的,但你在哪里调用函数列表?