Php 仅更新来自<;的值;col>;
所以我真的需要知道是否有可能更新表中特定列下的值Php 仅更新来自<;的值;col>;,php,javascript,jquery,html,ajax,Php,Javascript,Jquery,Html,Ajax,所以我真的需要知道是否有可能更新表中特定列下的值 <table> <col with="auto"> <col with="auto"> <col with="auto" id="update_me"> <?php for(hundreds of lines){ ?> <tr> <td>something 0</td> <td>someth
<table>
<col with="auto">
<col with="auto">
<col with="auto" id="update_me">
<?php
for(hundreds of lines){
?>
<tr>
<td>something 0</td>
<td>something 1</td>
<td>Need to update</td>
<tr>
<?php
}
?>
0
一点
需要更新
我将使用:
<script>
$(document).ready(function() {
$("#update_me").load("response.php");
var refreshId = setInterval(function() {
$("#update_me").load('response.php');
}, 6000);
$.ajaxSetup({ cache: false });
});
</script>
$(文档).ready(函数(){
$(“#update_me”).load(“response.php”);
var refreshId=setInterval(函数(){
$(“#update_me”).load('response.php');
}, 6000);
$.ajaxSetup({cache:false});
});
php将只从特定列生成值 我认为这更符合您的需求:
My Table
<table>
<tr>
<td width="auto"> </td>
<td width="auto"> </td>
<td width="auto" id="update_me1"></td>
<tr>
<tr>
<td width="auto"> </td>
<td width="auto"> </td>
<td width="auto" id="update_me2"></td>
<tr>
<tr>
<td width="auto"> </td>
<td width="auto"> </td>
<td width="auto" id="update_me3"></td>
<tr>
</table>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#update_me").load("response.php");
var arr = ['1','2','3'];
var refreshId = setInterval(function() {
$.each(arr, function() {
$('#update_me' + this).load('response.php');
});
}, 6000);
$.ajaxSetup({ cache: false });
});
</script>
否则,您需要调用response.php一次,并在javascript中解析数据。这些是您唯一的选择。我认为这更符合您的要求:
My Table
<table>
<tr>
<td width="auto"> </td>
<td width="auto"> </td>
<td width="auto" id="update_me1"></td>
<tr>
<tr>
<td width="auto"> </td>
<td width="auto"> </td>
<td width="auto" id="update_me2"></td>
<tr>
<tr>
<td width="auto"> </td>
<td width="auto"> </td>
<td width="auto" id="update_me3"></td>
<tr>
</table>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#update_me").load("response.php");
var arr = ['1','2','3'];
var refreshId = setInterval(function() {
$.each(arr, function() {
$('#update_me' + this).load('response.php');
});
}, 6000);
$.ajaxSetup({ cache: false });
});
</script>
否则,您需要调用response.php一次,并在javascript中解析数据。这些是你唯一的选择。我不明白为什么没有人提出建议
jQuery("td:nth-child(" + column_number + ")").each(function(row_number)
{
//Do something to this row's cell in column "column_number"
});
我不明白为什么没有人建议
jQuery("td:nth-child(" + column_number + ")").each(function(row_number)
{
//Do something to this row's cell in column "column_number"
});
$(文档).ready(函数(){
var refreshId=setInterval(函数(){
$.getJSON('response.php',函数(数据){
$.each(数据、函数(索引、值){
$('#value'+index).html(value.show();
});
});
}, 3000);
$.ajaxSetup({cache:false});
});
$(文档).ready(函数(){
var refreshId=setInterval(函数(){
$.getJSON('response.php',函数(数据){
$.each(数据、函数(索引、值){
$('#value'+index).html(value.show();
});
});
}, 3000);
$.ajaxSetup({cache:false});
});
确实可以做到这一点-查看表中每个tr的or选择器,具体取决于您的回复格式。您想给我举个例子吗?这似乎不太容易。。。我只想更新第三列,但我该如何引用它?
是非常无用的。大多数有用的属性不会强制转换到
下的
中。如果要更新所有行中的1列,则需要比使用
s更富想象力的javascript。抱歉=)编辑它还取决于您的响应格式。它是HTML中的1列吗?这很糟糕。确实可以这样做-查看表中每个tr的or选择器,这取决于您如何格式化您的响应。您想给我一个示例吗?这似乎不太容易。。。我只想更新第三列,但我该如何引用它?
是非常无用的。大多数有用的属性不会强制转换到
下的
中。如果要更新所有行中的1列,则需要比使用
s更富想象力的javascript。抱歉=)编辑它还取决于您的响应格式。它是HTML中的1列吗?太糟糕了,我明白了。。。但是,我可以在数百个表数据()上使用相同的id吗?在w3c下它是正确的?我认为它不会工作!它将所有的值放在第一个下面(由我的index.php生成)。因此,在第一次从php脚本加载值并正常工作时,jquery脚本将response.php中的值放在第一次下,其余的值保持第一次生成时的状态……根据CSS规范,每个ID都应该是唯一的。您可能需要尝试为您可以使用的每个TD实现一个类。我明白你现在的要求了。我会更新的。非常感谢。。。我将看看我能用我的编程技能做些什么:)这个网站上没有人知道如何拼写“宽度”吗?我明白了。。。但是,我可以在数百个表数据()上使用相同的id吗?在w3c下它是正确的?我认为它不会工作!它将所有的值放在第一个下面(由我的index.php生成)。因此,在第一次从php脚本加载值并正常工作时,jquery脚本将response.php中的值放在第一次下,其余的值保持第一次生成时的状态……根据CSS规范,每个ID都应该是唯一的。您可能需要尝试为您可以使用的每个TD实现一个类。我明白你现在的要求了。我会更新的。非常感谢。。。我将看看我能用我的编程技能做些什么:)这个网站上的任何人都不知道如何拼写“宽度”吗?它似乎也能工作,因为我不知道我将有多少行(它们将由php脚本生成),而且第一行仍然是一个问题,它是一个描述(不需要更新)$(document).ready(function(){var refreshId=setInterval(function(){$.get('response.php',function(data){$.each(data,function(index,value){$('#value'+index).html(value.show();});});},3000);$.ajaxSetup({cache:false});});这应该可以正常工作,但是正在打印“和”,以及值……怎么了?php数组是json_编码的,纯文本:header(“内容类型:text/plain”);echo json_encode($array);@FCC-PT jQuery的选择器不需要浏览器支持即可工作。它不需要知道有多少行,只需要知道要更新的列。您可以使用.not()
从选择器中删除第一行。我们可以看到您正在使用的json的一个小示例吗?它的工作非常完美$(document)。准备好了吗(function(){var refreshId=setInterval(function(){$.getJSON('response.php',function(data){$.each(data,function(index,value){$('#value'+index).html(value.show();});}},3000);$.ajaxSetup({cache:false});});它似乎也能工作,因为我不知道我将有多少行(它们将由php脚本生成),而且仍然是一个问题,第一行它是一个描述(不需要更新)…$(文档)。ready(function(){var refreshId=setInterval(function(){$.get('response.php',function(data){$.each(data,function(index,value){$('#value'+index.html(value.show();});}),3000);$。