I'm building this code to calla web service. Now I want that this method return an object.
So this is the command that call the method:
Titanium.API.info("CHIAMO IL WS CON DATA NULL");
getDocument("CFDECTEST02",null, function(obj) {
Titanium.API.info("CALL BACK CHIAMATA "+ obj);
});
This is the method that call web service:
function getDocument(fiscalCode, date){
var obj;
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(10000);
xhr.open('POST', "http://url");
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
var myObject = {
cf :fiscalCode,
date_last_synchronization :date
};
xhr.send(JSON.stringify(myObject));
xhr.onerror = function() {
Ti.API.info("SERVIZIO IN ERRORE");
Ti.API.info(this.responseText);
disattivaSemaforo();
};
xhr.onload = function() {
var obj = JSON.parse(this.responseText);
Ti.API.info(this.responseText);
return obj;
};
}
The problem is on the callback function. Because the method getDocument call correctly the web service and have a correct obj, but the callback function is not called.