HTTPClient in Titanium iPhone or ANDROID. How to check whether you request is complete?

By | February 10, 2011
function sendRequest()
{
	   var xhr = Titanium.Network.createHTTPClient();
	   xhr.onload = function()
	   {
		    if(this.status == 200)
		    {
		    	// this becomes true if your request is completed.
		    }
	   };
};
xhr.open('POST','http://your_domain.com/test.php');
xhr.send({ 'data':data});
xhr.onerror = function()
{
    Titanium.API.info('error');
    Titanium.UI.createAlertDialog({title:'Error ', message:'Please check your internet connection'}).show();
};

Leave a Reply

Your email address will not be published. Required fields are marked *