Is it good to use jQuery AJAX with traditional true?

点点圈 提交于 2019-12-01 02:24:16

jQuery API documentation

http://api.jquery.com/jQuery.Ajax/#jQuery-ajax-settings

traditional

Type: Boolean

Set this to true if you wish to use the traditional style of param serialization.

Let's have a look below, tranditional flag changes the way how parameters are sent to the server

For PHP developer

$.ajax(url, {
   data : { a : [1,2,3] },
   traditional : false
}));
// `data` are sent as "a[]=1&a[]=2&a[]=3"

For ASP.NET MVC developer

$.ajax(url, {
   data : { a : [1,2,3] },
   traditional : true
}));

// `data` are sent as "a=1&a=2&a=3"

As you can see, it is important to set traditional flag depending on your server side language.

So I guess, it won't be deprecated anytime in near future.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!