I want to send an Array with image paths and captions to a PHP script after I sorted the images.
I can do ‘serialize’ or ‘toArray’ on the lists, but how to get the attributes from the img tag?
<ul class="gallery">
<li id="li-1">
<img src="tn/001.jpg" alt="first caption" />
</li>
<li mycaption="some caption" id="li-2">
<img src="tn/002.jpg" alt="second caption with éèçà international chars" />
</li>
</ul>
$(".gallery").sortable({
update : function() {
serial = $('.gallery').sortable('serialize');
alert(serial);
/* $.ajax({
url: "sort.php",
type: "post",
data: serial,
error: function() {alert("theres an error with AJAX");}
}); */
}
});
So here’s how I would serialize this, into an object with two members,
src_arrandcaption_arr:So I’d do this with your code:
The raw data as
print_r()out ofsort.phplooks like: