XHR send multi-dimensional array
Hi,
Just wondering why single arrays are sent fine using createHTTPClient() and complex arrays aren't. Am I doing something wrong? Here is what I am doing:
Works fine:
var xhr = Titanium.Network.createHTTPClient();
xhr.open("POST",'http://api.com/names);
//code here
xhr.send({name:'Jim'});
Doesn't work at all:
var xhr = Titanium.Network.createHTTPClient();
xhr.open("POST",'http://api.com/names);
//code here
var names = new Array();
names.push({name: 'Jim Bob', DOB:'29-06-1985'});
names.push({name: 'Sam Smith', DOB:'15-02-1972'});
xhr.send(names);
And at the server end I have a RESTful API that's just printing out the $_POST vars to see whats coming through.
The second options just prints a blank $_POST response where the other doesn't. It comes out fine. Why wont my complex array?
Anyone see what I might be missing?
Ian
2 Answers
-
i think to be able to send multidimensional arrays, you have to json-encode them and send it as you do in your working example
-
Ahh I see. Would you have an easy way to do that with Titanium that you know of?