topical media & game development
mobile-application-10-DerbyApp-Resources-network-odata.js / js
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();
};
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.