[TIMOB-17432] iOS: HTTPClient not fire onload onerror when set option async false
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2014-09-05T18:06:39.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | SDK3.3.0 |
Reporter | Tadatoshi Hanazaki |
Assignee | Ingo Muschenetz |
Created | 2014-07-18T15:55:55.000+0000 |
Updated | 2017-03-20T22:25:07.000+0000 |
Description
It's seems to HTTPClient.open doesn't work when set async = false.
var win = Ti.UI.createWindow({backgroundColor:'white'});
var button1 = Ti.UI.createButton({
title:'GET async=false',
top:'15%',
});
var button2 = Ti.UI.createButton({
title:'GET async=true',
top:'30%',
});
button1.addEventListener('click', function () {
this.title = 'sending...';
var onload = function(e) {
Ti.API.debug('onload responseText='+this.responseText);
button1.title = 'onload';
};
var onerror = function(e) {
button1.title = 'onerror';
};
var _xhr = Ti.Network.createHTTPClient({
onload: onload,
onerror: onerror,
cache: false
});
var url = 'http://ip.jsontest.com/';
_xhr.open('GET', url, false);
_xhr.timeout = 5000;
_xhr.send();
});
button2.addEventListener('click', function () {
this.title = 'sending...';
var onload = function(e) {
Ti.API.info(String.format('onload e = %s', e||{}));
Ti.API.debug('onload responseText='+this.responseText);
button2.title = 'onload';
};
var onerror = function(e) {
Ti.API.error(String.format('error e = %s', e||{}));
button2.title = 'onerror';
};
var _xhr = Ti.Network.createHTTPClient({
onload: onload,
onerror: onerror,
cache: false
});
var url = 'http://ip.jsontest.com/';
Ti.API.debug('url = '+url);
_xhr.open('GET', url, true);
_xhr.timeout = 5000;
_xhr.send();
});
win.add( button1 );
win.add( button2 );
win.open();
Expected Result : when tap both button1 and button2 text should change to "onload" or "onerror".
Actual Result: only button2 works. button1 text stays "sending..."
Hi, Tested with your code. Can reproduce your problem on SDK 3.3.0.GA. But It works well in SDK 3.2.3GA. I will forward this ticket to our engineer team to get this fixed. Thanks Regards, Shuo
Closing ticket as duplicate.