Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created October 3, 2011 19:55
Show Gist options
  • Select an option

  • Save jonalter/1260060 to your computer and use it in GitHub Desktop.

Select an option

Save jonalter/1260060 to your computer and use it in GitHub Desktop.
Test setRequestHeader
var win = Ti.UI.createWindow({
backgroundColor : 'white',
fullscreen : true
});
var button = Ti.UI.createButton({
title : 'test',
height : 60,
width : 200
});
win.add(button);
button.addEventListener('click', function(e) {
var xhr = Titanium.Network.createHTTPClient();
xhr.open('GET', 'http://10.0.15.101/~jalter/test/index.php');
xhr.onerror = function(e) {
alert(e.error);
Ti.API.info('error: '+e.error);
};
xhr.setTimeout(200000);
xhr.onload = function(e) {
Ti.UI.createAlertDialog({
title : 'Success',
message : this.responseText
}).show();
Ti.API.info('onload: '+this.responseText);
};
xhr.onsendstream = function(e) {
Ti.API.info(e);
};
xhr.setRequestHeader('Content-Type','application/json');
xhr.send();
});
win.open();
<?php
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment