jquery serialize not sorted?
I have a javascript function that reads an entire form into a serialized
$.ajax({
type: 'POST',
url: '/cart/update.js',
dataType: 'json',
data: $("#add-to-cart").serialize() + '&id=' + $("select[name=id]").val(),
success: goToCart,
error: goToCart
});
However it seems to be not org开发者_如何学Canizing the data. It should be pattern, line 1, line 2, line 3, line 4, line 5, line 6
, however it seems to be going line 1, line 2, line 3, line 4, pattern, line 5, line 6
.
Is there a way to sort the serialized data somehow?
html is in proper order, pattern is first then lines 1-6.
Any help?
You will have to write your own sort method there is no direct way to do it.
Take a look at this.
Sorting JavaScript Object by property value
精彩评论