开发者

jquery serialize not sorted?

开发者 https://www.devze.com 2023-03-13 19:06 出处:网络
I have a javascript function that reads an entire form into a serialized $.ajax({ type: \'POST\', url: \'/cart/update.js\',

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号