Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Last active February 23, 2016 18:11
Show Gist options
  • Save tzmartin/47150cbe4190b43cde59 to your computer and use it in GitHub Desktop.
Save tzmartin/47150cbe4190b43cde59 to your computer and use it in GitHub Desktop.
Example Titanium JSON POST

Request

var xhr = Ti.Network.createHTTPClient();
xhr.onload = function() {
	Ti.API.info(this.responseText);	
}
var payload = {
	"foo":{
		"foo":"bar"
	}
};
xhr.open('POST',"http://requestb.in/wfvbbowf");
xhr.setRequestHeader('Content-Type','application/json')
xhr.send(JSON.stringify(payload));

Response

Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment