I need to sort items from multiple columns. I use this to get the id from the columns and format the data:

$.fn.serial = function() {
    var array = [];
    var $elem = $(this); 
    $elem.each(function(i) {
        var id = this.id;
        $(move_selector, this).each(function(e) {
            array.push( 'id[]=' + this.id  );
        });
    });
    var data = array.join('&');  
    //console.log(data);
    return data;    
};

$(function() {
    $("div.connectedSortable").sortable({
        connectWith: '.connectedSortable',
        update: function(event, move_selector) {
            $('#data').empty().html( $('.connectedSortable').serial() );
            var datatest = $('#data').text();
            //$('#test').text(datatest)
            console.log(datatest);
        }
    }); 
});

This gets the data to the console.log but I can't seem to get it into a variable that I can use for the ajax request.
This kind of works:

    $('#sub_butt').click(function(event){
        var datatest = $('#data').text();
        $.ajax({
            beforeSend: bs,
            complete: comp,
            data: datatest,
            type: 'POST',
            url: subphp,
            inline : true
        });
        event.preventDefault();
    }); 

It can do this without the "connectWith" (With one column), but can't seem to do it with it.

Recommended Answers

All 2 Replies

What was displayed on the console log? And what did you get in Ajax? Did you sort it before you pass to Ajax?

Sorry for the delayed reply. Turned out to be a corrupt database. All the logs come back ok. But the database would only half or randomly update.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.