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();
location.href="test.php?" + $.tableDnD.serialize();
}
});
});
</script>
And it sends through a refresh location.href
all the data to the following script:
<?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'");
}
}
}
?>
What I'd like to do is send the data using ajax, and this is what I have so far, but it's not working:
<script type="text/javascript">
$(document).ready(function() {
// Initialise the table
$('#table_1').tableDnD({
onDrop: function(table, row) {
$.tableDnD.serialize();
$.ajax({
type: "GET",
url: "test.php",
data: "?"+$.tableDnD.serialize(),
success: function(html){
alert("Eureka!");
}
});
}
});
});
</script>