每次删除div时调用PHP函数(Calling PHP function each time a div is dropped)
我有一个可拖动的元素,我想在每次删除元素时调用PHP函数(基本上是为了保存它的位置 - 像素从顶部和左边到mysql数据库)。 如何接近它? AJAX?
I have a draggable element and I would like to call PHP function each time the 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); } });编辑
如果你想要draggable的id(而不是它的内容),你需要在设置drop回调时使用ui参数:
$( "#draggable" ).draggable(); $("#droppable").droppable({ drop: function(event, ui) { $.get('http://mysite.com/dragged.php?droppedID='+ui.draggable.attr('id')); } }); $("#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')); } });更多推荐
发布评论