JQuery parameter serialization without the bracket mess

后端 未结 2 1625
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 07:31

I\'m using JQuery to make a JSON request back to the server and it seems that it\'s parameter serialization is hard-coded to what PHP expects instead of being generic in nat

2条回答
  •  一向
    一向 (楼主)
    2020-12-05 08:03

    I'm assuming you're using JQuery 1.4. You should take a look at this: http://benalman.com/news/2009/12/jquery-14-param-demystified/

    The author discusses why they made JQuery behave this way, and makes some excellent points. For example, if you don't use the "square bracket syntax", you can't pass in arrays with only a single value.

    He also offers a work-around:

    $.ajaxSetup({ traditional: true });
    

    This will tell JQuery to use the non-bracket method of serialization.

提交回复
热议问题