Created
November 5, 2019 17:21
-
-
Save MotiurRahman/130b7f232a74956b0c26d7ddf4ac6b34 to your computer and use it in GitHub Desktop.
Remote image response data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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