我有以下的代碼工作:
<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