mardi 18 mars 2014

How should I POST nested parameters to a remote server?

Sencha touch seems to serialize the extraParams on a Proxy in unexpected way when it contains anything other then key-value pairs. The documentation doesn't have much to say on the expected behavior: http://ift.tt/1j0jUav



Source code to reproduce the issue is located here: http://ift.tt/1j0jUqN.



To reproduce my issue, try and load the application, then look in the javascript console for a request to "/api/remote_route." The parameters should look like what's in the attached screenshot.



(1) The value of key_1 is sent to the server as expected. This is the simple key-value case.



(2) object_param is sent over to the server in key value form object_param: object_1. This is the case where the parameter value is an object.



(3) array_of_objects is sent to the server as the string "[object Object]". This is the case where the parameter value is an array of objects.



The behavior of (2) I find strange and undocumented. (3) I suspect is a bug.



What is the advised way to POST nested object parameters to a remote server?


Attached Images






Aucun commentaire:

Enregistrer un commentaire