I am trying to send my serialized sort data to my PHP script, but I need to add two other variables to the post request.
This is the code I am using, but I cannot seem to get the additional data added to the data attribute of the post.
the other two variables are plain strings. I have looked, but no matter what I try, it seems to screw up the serialized sort data.
I just need to send:
var album
var ID
with the request, but can’t seem to get the concantination right
$(function() {
$('#refloader').hide();
$( "#images" ).sortable({
stop:function(event, ui) {
$('#refloader').show();
$.ajax({
type: "POST",
url: "http://#######/sort.php",
data: $("#images").sortable("serialize", {attribute : "data-id"}),
success : function(response)
{
console.log (response)
$('#refloader').hide();
$("#ajaxresponse").append($(response));
}
});
}
});
$( "#images" ).disableSelection();
});
when I use:
data: $("#images").sortable("serialize", {attribute : "data-id"}),
i get back :
Array ( [0] => 2213132022 [1] => 2213131911 [2] => 2213130084 [3] => 2213130956 [4] => 2213129315 [5] => 2213128885 [6] => 2213129567
when i use:
data: { image : $("#images").sortable("serialize", {attribute : "data-id"}) },
I get back:
image[]=2213129776&image[]=2213132022&image[]=2213131911&image[]=2213130084&image[]=2213130956&image[]
Try adding this parameter to your ajax
you would normally wrap them all in an object