Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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!!!

— asked April 20th 2010 by Jonathon Morgan
  • ajax
  • php
  • post
  • xhr
0 Comments

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

    — answered April 20th 2010 by Raul Riera
    permalink
    0 Comments
  • Thanks Raul! I'd tried send({comment: "my comment"}) with no luck but will give the syntax above a shot.

    — answered April 21st 2010 by Jonathon Morgan
    permalink
    0 Comments
  • Is you $_POST working now if yes can you tell me how did you do it..

    — answered May 3rd 2010 by Murtaza Ali
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.