jQuery Droppable - Make an Update Statement after an element gets dropped

Go To StackoverFlow.com

0

I want to do an update statement in my database, after an element gets dropped on a jQuery UI droppable element.

$("#pictures th div").droppable({drop: function(ev, ui) { 
    alert('You filled this box with a picture');
    var this_id = $(ui.draggable).attr("alt");
    var draggableId = ui.draggable.attr("id"); 
}

I know how to get the information (see the code above) I need, but how can I put them now into the database ?

Thank you !

2012-04-03 19:35
by user1124288
This is a very open-ended question. You haven't told us what information you want to put into your database, or even what type of database it is (although I assume mySQL given your PHP tag - Rory McCrossan 2012-04-03 19:37
I want to update my Table AlbumPosition with the name of picture, which is in this case "this_id" und the id of object it was dropped in (draggableId). Sry, forgot about the type of the database, but yes it is a mySQL Database.

This update Statement shouldn´t require a reload of the page - user1124288 2012-04-04 07:27



1

At this point, you can use jQuery's $.post() method to post to a PHP file you've written. In the $.post(), you can pass the ids you would like to have written to your database.

So something like this:

$.post("/save.php", { imageId: this_id, draggedId: draggableId }, function (data) {
    alert("success!");
});
2012-04-03 19:43
by Tuan
Thank You ! This one works perfect in my case ; - user1124288 2012-04-04 12:58


0

Post the variable values to other page lyk this:

     $.ajax({
 type: "POST",
 url: "data.php",
 data: "Cat=" + id + "&Wid=" + WID
 });  

and then on data.php page get the values lyk this:

 $Cat=$_POST['Cat'];
    $WID=$_POST['Wid'];     

simply store them in database by using insert query,hope it will help you.

2013-12-14 14:49
by user3102186
Ads