HTTPClient Error Handling
Hi there
I have the following httpclient code:
The first commented loadRSSFeed call is successful because the address is on the local LAN. The second one that loads http://www.google.com however fails after some time. I think there is some kind of proxy issue here but I'm not sure how to check on the error result. What properties does the "e" object in my xhr.onerror = function(e) have so that I can troubleshoot this? On a sidenote the Android emulator can access http://www.google.com through the native browser. This I got working by setting the proxy address port username etc on the phone itself.
Please help.<br>
Many thanks.<br>
-De Wet<br>
2 Answers
-
Accepted Answer
make on_err
function(e) { alert(e.error); }
-
I do this:
var r_ajax = function(url,on_ok, on_err, method) { var method = !!method ? method : 'POST'; var xhr = Titanium.Network.createHTTPClient(); xhr.onload = on_ok; xhr.onerror = on_err; xhr.open(method,url); return { xhr:xhr, send:function(data) { xhr.send(data); } }; };
I set onload first , then open
( this is tested on iPhone )