I have the following code that works:
<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>
Sending data to 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'");
}
}
}
?>
As you can see the table_1 array retrieves the data using $_GET, but that ajax code says we're sending with POST. If I change $_GET to $_POST it no longer works. Why is this?