Skip to content

Instantly share code, notes, and snippets.

@MotiurRahman
Created November 5, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MotiurRahman/130b7f232a74956b0c26d7ddf4ac6b34 to your computer and use it in GitHub Desktop.
Save MotiurRahman/130b7f232a74956b0c26d7ddf4ac6b34 to your computer and use it in GitHub Desktop.
Remote image response data
var win = Ti.UI.createWindow({
backgroundColor : '#fff'
});
function getImage() {
var url = "https://tineye.com/images/widgets/mona.jpg";
var response = '';
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received Data: " + this.responseData);
if (this.responseData) {
response = this.responseData;
var imageView = Ti.UI.createImageView({
image : response,
width : Ti.UI.SIZE,
height : Ti.UI.SIZE
});
win.add(imageView);
}
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.open("GET", url);
// Send the request.
client.send();
}
getImage();
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment