Calling PHP function each time a div is dropped
I have a draggable element and I would like to call PHP function each time th开发者_运维百科e element is dropped (basically to save its position - pixels from top and left to mysql database). How to approach it? AJAX?
$("#droppable").droppable({
drop: function() {
$.get('http://mysite.com/dragged.php?droppedID='+this.id);
}
});
EDIT
If you want the id of the draggable (and not what it was dropped on), you need to use the ui
parameter when you setup the drop
callback:
$( "#draggable" ).draggable();
$("#droppable").droppable({
drop: function(event, ui) {
$.get('http://mysite.com/dragged.php?droppedID='+ui.draggable.attr('id'));
}
});
AJAX sounds like a very good idea, yes.
JQuery HTTP methods. It is more simple than AJAX, I always use it!
精彩评论