Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Created August 12, 2014 18:20
Show Gist options
  • Save ricardoalcocer/971042db3a2c44cb45f3 to your computer and use it in GitHub Desktop.
Save ricardoalcocer/971042db3a2c44cb45f3 to your computer and use it in GitHub Desktop.
Test Titanium HTTPClient
var w=Ti.UI.createWindow({
backgroundColor: "#fff"
});
var s=Ti.UI.createScrollView({
height: Ti.UI.FILL,
width: Ti.UI.FILL
})
var t=Ti.UI.createLabel({
height: Ti.UI.FILL,
width: Ti.UI.FILL,
color: "#000",
text: "...loading..."
});
s.add(t);
w.add(s);
var url = "https://gdata.youtube.com/feeds/api/videos?q=skateboarding+highest+ollie&orderby=published&start-index=1&max-results=50&v=2&alt=json";
var client = Ti.Network.createHTTPClient({
onload : function(e) {
t.text=this.responseText;
},
onerror : function(e) {
t.text=e.error;
},
timeout : 5000
});
client.open("GET", url);
client.send();
w.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment