lucemia
lucemia

Reputation: 6627

jquery ajax pass data which has multiple value with the same key

Is there a easy way to build an ajax query like this with jquery?

http://www.test.com/?value=happy&value=good&value=day

I tried

$.getJSON('http://www.test.com/', {'value': ['happy','good','day']});

but the result becomes http://www.test.com/?value[]=happy&value[]=good&value[]=day

Upvotes: 7

Views: 2901

Answers (2)

mpcabd
mpcabd

Reputation: 1807

Just for anyone who comes here through search, you can use the traditional parameter to $.ajax and set it to true then you will get:

http://www.test.com/?value=happy&value=good&value=day.

Upvotes: 6

Kristóf Dombi
Kristóf Dombi

Reputation: 3967

This url seems to be good:

http://www.test.com/?value[]=happy&value[]=good&value[]=day

in php you can access the values like an array

Upvotes: -1

Related Questions