0

In the below code, I also want to pass the value listing_id in my AJAX post:

$('#listing .images').sortable({
    tolerance: 'pointer',
    update: function(event, ui){
        var data = $(this).sortable('serialize');
        var listing_id = $('#listing').attr('data-id');

        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'listings/sortimages',
            data: data,
            success: function(result){
                alert('Successfully re-ordered items.');
            }
        });
    }
});

I have tried:

data.push({name: 'listing_id', value: listing_id});

It says data.push is not a function.

1 Answer 1

4
data.push({name: 'listing_id', value: listing_id});

doesn't work because data is a serialized string. Try

data += '&listing_id=' + listing_id;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.