0

I would like to know if i can send an array of this type endate [] in the parameter fecha2 of the following url:

http://www.xxxx.com/app/disponibilidad?idUser&fecha2&fecha1&desde&hasta

endate[] has several date I want to send in a single url. I would like to know if that is possible

jeanf
  • 365
  • 1
  • 3
  • 12

1 Answers1

2

You can get a good idea in How to pass an array within a query string?

You can also encode it to JSON and pass it as a single string, then decode it on your backend. Sounds simpler to me.

Ricardo Paixao
  • 324
  • 2
  • 10
  • Thanks for the reply, how to address the json encoding to the server www.xxxx.com/app/ disponibilidad – jeanf Jun 27 '17 at 19:42
  • You can create a JSON string from an array with Javascript's function`JSON.stringify(arr);` – Ricardo Paixao Jun 27 '17 at 21:04
  • If you're thinking in pass a json as a query parameter, I think you may use a post instead of a get – pedrohreis Jun 28 '17 at 00:19
  • But as concatenary this url: http://www.xxxx.com/app/prueba url. With this json: {"disponibilidad":[{"idUser":"4","fecha2":"30 June, 2017","fecha1":"28 June, 2017","slotH":"1 hora","desde":"11:00 AM","hasta":"03:00 PM","entre":"10 minutos"},{"idUser":"4","fecha2":"30 June, 2017","fecha1":"29 June, 2017","slotH":"30 minutos","desde":"04:00 PM","hasta":"06:00 PM","entre":"15 minutos"}]} – jeanf Jun 28 '17 at 13:17
  • if you wish to pass all that as GET parameters, then concatenate it as `"xxxx.com/app/disponibilidad?Myarray="+JSON.stringify(arr)` – Ricardo Paixao Jun 28 '17 at 18:09