Query String generated by $.param() include square brackets for array

前端 未结 2 1937
死守一世寂寞
死守一世寂寞 2021-01-15 06:31

I have an object like this:

var queryObject= {
      name: \'Shwetanka\',
      subjects: [\'Mathematics\', \'Physics\', \'Computers\'],
      stream: \'scie         


        
2条回答
  •  天命终不由人
    2021-01-15 06:39

    When we have fields with same name in a form and it is submitted via GET/POST, it is bound to be send as an array of params with the same name. And the server would be expecting the values as such. So, Even if you somehow remove that [], it ceases to be an array, and the server will get only one value. jQuery param method is designed, with the same thing in mind. Check out examples in http://api.jquery.com/jQuery.param/.

提交回复
热议问题