Jquery serializePost()
jQuery has a couple of useful functions that you should be using quite a lot. .serialize() and .serializeArray().
These useful functions will take your form and spit out something you can send off in your ajax requests.
“Awesome” you exclaim! “I’ll use it to send my post“.
Not so fast!
Turns out these functions are more or less useless for post requests.
That’s where this nifty little function comes in handy. call $('form').serializePost() on your form and it will serialize your post data and return a nice little javascript object ready to send off. On the other end you can access it as if you had submitted the form normally using $_POST['myField'].
(function($) {
$.fn.serializePost = function() {
var data = {};
var formData = this.serializeArray();
for (var i = formData.length; i--;) {
var name = formData[i].name;
var value = formData[i].value;
var index = name.indexOf('[]');
if (index > -1) {
name = name.substring(0, index);
if (!(name in data)) {
data[name] = [];
}
data[name].push(value);
}
else
data[name] = value;
}
return data;
};
})(jQuery);

Where is the demonstration
Hi!
I completely forgot about a demo!
Expect one in the next 24 hours!
Excelente Plugins…..saludos
Does this sort the posts in reverse? I seem to get the list of items backwards for posted array elements. Maybe I’m out to lunch…
-L
In your for loop you are counting down from a total number of form inputs. I changed your for loop to the following and could reference the inputs by array key. This way the array of posts are in the same order as the form elements instead of reversed. I needed to do this for a drag and drop reordering
//the for loop
for(var i=0; i<form.length; i++){
}
TNX!!!!!!