Skip to content

Instantly share code, notes, and snippets.

@PaluMacil
Created September 27, 2016 15:06
Show Gist options
  • Save PaluMacil/12267255ba8c337e1b5ae90c439ce5cd to your computer and use it in GitHub Desktop.
Save PaluMacil/12267255ba8c337e1b5ae90c439ce5cd to your computer and use it in GitHub Desktop.
This is how JQuery passes an array in a GET request.
//This is how JQuery passes arrays in a GET request
var tdata = { one: 1, two: 2, three: ["a", "b", "c"]};
$.get("/test", tdata, function (data) { console.log("All done!"); });
//http://example.com/test?one=1&two=2&three%5B%5D=a&three%5B%5D=b&three%5B%5D=c
/*Broken down...
http://
example.com/
test?
one=1 &
two=2 &
three %5B%5D=a &
three %5B%5D=b &
three %5B%5D=c
%5B%5D decodes to []
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment