function odata(){ this.getData = function (requestString, successFunction){ if (Titanium.Platform.name == 'android') { requestString = requestString.replace(/\s/g, '%20'); } var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function () { var response = JSON.parse(this.responseText); var result = response.d.results; // for some reason oData will return it both ways, in .d and .d.results if (result == null) { result = response.d; } var gotData = new Date(); successFunction(result); }; xhr.onerror = function (e) { Titanium.UI.createAlertDialog({ title: 'Error retrieving data', message: 'An error occurred retrieving data. Please try later.' }).show(); Titanium.API.error(requestString); }; xhr.open('GET', requestString); xhr.setRequestHeader('Accept', 'application/json'); var send = new Date(); xhr.send(); }; }