I have python api which can get the multiple data in same query such as.
createdata?ob=120&st=cool&st=warm
It can get st as ["cool","warm"] in python.
st = request.query_params.getlist("st")
print(st) #["cool","warm"] get the data as array.
Now I want to do the same thing from ajax
I try this
$.ajax({
type: "POST",
url: "defapp/createdata",
method: "GET",
data: {"ob":130,"st":"warm","st":"cool"},
contentType: "application/json",
and this.
$.ajax({
type: "POST",
url: "defapp/createdata",
method: "GET",
data: {"ob":130,"st":["warm","cool"]},
contentType: "application/json",
However former one get ["cool"] as st
later one get [] as st.
It's don't work,because you api not recive a data body,but it recive a params value.
You can changed to these below.
$.ajax({
type: "POST",
url: "defapp/createdata?ob=120&st=cool&st=warm",
method: "GET",
data: {},
contentType: "application/json",
I hope is can work in your case.