xhr post not sending data
Hi all,
I've been having trouble getting the following to send data:
var xhr = Titanium.Network.createHTTPClient();
xhr.open('POST','url-of-a-working-php-script');
xhr.send({"comment":"my comment"});
Grabbing "comment" with $_POST['comment']. Set up a quick jQuery ajax function outside of my app to make sure the script was receiving and process data correctly, and all seems to be working on that end. And I can successfully send with "GET", but "POST" doesn't seem to work. Is there anything else I need to do?
Thanks in advance for your help!!!
3 Answers
-
I think you want this
var data = {}; data.comment = "my comment"; xhr.send(data);
You are sending an JS object and not a "JSON string" somehow inside an object right?
UPDATE ON THE CODE
-
Thanks Raul! I'd tried send({comment: "my comment"}) with no luck but will give the syntax above a shot.
-
Is you $_POST working now if yes can you tell me how did you do it..