0
我有jQuery和PHP的,我通过jQuery的$.post
发布的数据,但不能使得到的问题,在未来的页面数据,请healp问题张贴在jQuery的数据到PHP页面
jQuery代码
<?php
include 'dbconnect.php';
$query=mysql_query("select * from test");
?>
<html>
<head>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript">
$(function(){
$("button").click(function(){
var aid = $(this).attr("id");
var value=$("#id"+aid).val();
value++;
$("#id"+aid).val(value);
var val= $("#id"+aid).val();
$.post("test_sub.php", {id:"aid", name: "val"}, function(){
alert(aid);
});
});
});
</script>
</head>
<body>
<?
$i=0;
while($res=mysql_fetch_row($query))
{
$i++;
$point=$res[1];
$id=$res[0];
?>
<tr>
<td>
<input type="text" id="id<?=$id?>" name="user" value="<? echo $point; ?>" />
<button id="<?=$id?>" class="button">Change value for the text field</button>
</td>
</tr>
</body>
<?
}
?>
</body>
</html>
PHP代码
<?php
include 'dbconnect.php';
$id = $_POST['id'];
$name = $_POST['name'];
$sql="update test set name='fdf' where id=$id";
$query=mysql_query($sql) or die(mysql_error());
?>
在此页面中我没有得到,如果的价值和
$_post['name']
任何人有解决方案,请帮我
你用过Firebug的,看看是否值实际上得到提交呢? – 2010-06-01 19:27:19