开发者

Calling PHP function each time a div is dropped

开发者 https://www.devze.com 2023-03-16 05:16 出处:网络
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 a

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消