I have this droppable Jquery along with two pieces of data I want to send to a PHP file when the object gets dropped:
$( function() {
$( ".draggable" ).draggable();
$( ".droppable" ).droppable({
drop: function( event, ui ) {
var playerid = ui.draggable[0].getAttribute("data-playerid");
var value = jQuery(this).data('value');
console.log(playerid);
console.log(value);
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" );
$.ajax({
type: "POST",
contentType: 'application/json; charset=utf-8',
url: "ajax-update-value.php",
data: {playerid:playerid, value:value},
success: function(result) {
// do something with the result of the AJAX call here
alert(result);
}
});
}
});
});
And in the PHP file, I want to use those two specific values to update my MySQL database. I have this below, but it's not pulling in the values, so I'm obviously doing something wrong/stupid. What is the proper way to access the two pieces of data?
$playerid=$_POST['playerid'];
$value=$_POST['value'];