POST a JSON array with Titanium Mobile
I must be trying too hard or there seems to be an error with the way JSON is being POSTed.
The following structure works for example with jQuery:
xhr.send({
'object': { 'child1':'value', 'child2':'value' }
});
But it's not nesting correctly with Titanium Mobile.
My web app keeps seing something like object = "{\'child1\' ...
Am I doing something wrong or is this is a platform bug?
Thanks for any help.
2 Answers
-
Are you sure you can send a nested json over http?
You may try this:
xhr.send({ object: { child1:'value', child2:'value' } });
or if it doesn't work, you can try to stringify the json, send it as a simple string variable and parse it serverside.
-
function setTask(idUser, idService, Reason){ xhrPost.open('POST', myPost); xhrPost.send({'User':idUser,'c':'mark','ServiceTick':idService,'Reason':Reason}); };
works so in my case
Andrea