我有以下的代码工作:
<script type="text/javascript">
$(document).ready(function() {
// Initialise the table
$('#table_1').tableDnD({
onDrop: function(table, row) {
$.tableDnD.serialize();
$.ajax({
type: "POST",
url: "test.php?"+$.tableDnD.serialize(),
data: "",
success: function(html){
alert("Success");
}
});
}
});
});
</script>
将数据发送到test.php的:
<?php
$table_1[] = $_GET['table_1'];
$i = 0;
if(!empty($table_1[0])){
foreach($table_1 as $value) {
foreach($value as $row){
$i++;
mysql_query("UPDATE mytable SET tableOrder='$i' WHERE id = '$row'");
}
}
}
?>
正如你可以看到TABLE_1阵列检索使用$ _GET的数据,但Ajax代码说我们用POST发送。如果我将$ _GET更改为$ _POST,则不再有效。为什么是这样?
您忘记了删除?在url后面。 (请参阅下面的示例) – RJD22 2010-01-31 22:48:10
不管使用什么方法,在url中传递的任何数据总是被视为GET。 – 2010-01-31 22:48:19
@ RJD22:谢谢...修复它:) – 2010-01-31 22:57:40