Reputation: 2765
I am trying to send the results of the current drag drop state back to mysql using ajax/php.
The console .log works fine..
With some help the drag and drop jquery feature is all working perfectly however sadly jquery/ajax is really not in my bag of tricks ..
http://jsfiddle.net/ambiguous/FMKmj/ (Credit mu)
Tearing my hair out , any ideas ?
Upvotes: 0
Views: 99
Reputation: 14625
If you just want to submit the groups hash, do it like:
$('#submit').click(function() {
var groups = { };
$('.sort').each(function() {
var a = [ ];
$(this).find('li').each(function() {
a.push(this.id);
});
groups[this.id] = a;
});
console.log(groups);
$.ajax({
url: "yourscript.php",
data: groups,
success: function(){
alert('sent!');
}
});
});
Upvotes: 1
Reputation: 3742
Notice that in the JQuery UI doc for sortable there is an event tab: here. So you have to bind an event to an Ajax call inside the event handling function called when a block is dropped in a new box.
It means you have to write your Ajax call: see here. Typically, you will do a post request since moving a block from a place to another place will change something on the server side. What do you send to the server ? Basically you want to send to the server which block has moved where. But it is up to you, you can send whatever you want, it depends on you server side application.
The server based on this information can execute MySQL requests.
Upvotes: 1