Created
June 23, 2011 05:00
-
-
Save aaronksaunders/1041936 to your computer and use it in GitHub Desktop.
use only one instance of the httpClient?
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 serviceList = []; | |
var xhr; | |
var tmpSvc = fetchServicesByProfile(Titanium.UI.currentWindow.profileid); | |
for(i=0;i<tmpSvc.length;i++) | |
{ | |
//Populate serviceList array. | |
} | |
function processServiceList(index) | |
{ | |
var serviceinfo = serviceList[index]; | |
// use only one httpclient | |
if ( xhr == null ) { | |
xhr = Ti.Network.createHTTPClient(); | |
} | |
var requestURI = '<appropriate uri here>'; | |
xhr.open("GET",requestURI); | |
xhr.onload = function() | |
{ | |
if (this.readyState == xhr.DONE && this.status == 200) | |
{ | |
var doc = this.responseXML.documentElement; | |
if (index < serviceList.length - 1) | |
{ | |
processServiceList(index + 1); | |
} | |
else | |
{ | |
//Ti.API.debug('done with this.'); | |
//loadStreamsIntoTableView(Titanium.UI.currentWindow.profileid); | |
} | |
} | |
} | |
xhr.send(); | |
} | |
processServiceList(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment