passing data to php
passing data to php
Hi All
I have a jquery script that allows me to drag and drop multiple widgets across multiple columns. The code is below.
What I am trying to achieve is to update a database to remember the positions of the widgets on the stage and their open/closed state.
-
$(function(){
$('.dragbox')
.each(function(){
$(this).hover(function(){
$(this).find('h2').addClass('collapse');
}, function(){
$(this).find('h2').removeClass('collapse');
})
.find('h2').hover(function(){
$(this).find('.configure').css('visibility', 'visible');
}, function(){
$(this).find('.configure').css('visibility', 'hidden');
})
.click(function(){
$(this).siblings('.dragbox-content').toggle();
})
.end()
.find('.configure').css('visibility', 'hidden');
});
$(document).ready(function(){
function slideout(){
setTimeout(function(){
$("#response").slideUp("slow", function () {
});
}, 5500);}
$('.column').sortable({
connectWith: '.column',
handle: 'h2',
cursor: 'move',
placeholder: 'placeholder',
forcePlaceholderSize: true,
opacity: 0.4,
stop: function(event, ui){
$(ui.item).find('h2').click();
var sortorder='';
$('.column').each(function(){
var item_order=$(this).sortable('toArray');
var columnId=$(this).attr('id');
sortorder+=columnId+'='+item_order.toString()+'&';
});
/*alert(sortorder);*/
/*Pass sortorder variable to server using ajax to save state*/
console.log(sortorder);
$.get('updateDesktop.php', sortorder, function(Response){
$("#response").html(Response);
$("#response").slideDown('slow');
slideout();
});
}
})
.disableSelection();
});
});
The output I get from the post data is like so
column1=2,1&column2=&column3=3&column4=&
What I want to know, is anyone able to point me in the right direction to update the database. Does a change of JS need to be done to output the variables differently or can I get the data sorted correctly on the server side?
TIA
Mark