Created
July 15, 2011 17:47
-
-
Save benbahrenburg/1085149 to your computer and use it in GitHub Desktop.
Android XHR issue
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
bGet.addEventListener('click', function(){ | |
var _url = "https://my.url.goes.here"; | |
var username='demo'; | |
var password='badpass'; | |
var aToken = 'Basic ' + Ti.Utils.base64encode(username + ':' + password); | |
var c = Titanium.Network.createHTTPClient(); | |
c.setTimeout(10000); | |
c.onload = function(e) | |
{ | |
Ti.API.info("ONLOAD = "+e); | |
Ti.API.info('this.status=' + this.status); | |
var results = this.responseText; | |
Ti.API.info('results=' + results); | |
}; | |
// c.ondatastream = function(e){ | |
// Ti.API.info('ONDATASTREAM1 - PROGRESS: ' + e.progress); | |
// }; | |
c.onerror = function(e) | |
{ | |
Ti.API.info('this.status=' + this.status); | |
Ti.API.info('c.status='+ c.status); | |
Ti.API.info(this.responseText); | |
Ti.UI.createAlertDialog({title:'XHR', message:'Error: ' + e.error}).show(); | |
}; | |
c.open('GET',_url); | |
c.setRequestHeader("Authorization", aToken); | |
c.send(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment