I working on iphone Application Development.
I created a sampleTest button and whenever i click on it the following function invoking.
But unable to return any response. Its showing empty alert message.
(hostName and portNo are dynamic inputs)
sampleTestBtn.addEventListener('click', function()
{
var regDetails = '{"user_login": {"email": "sample@sample.com", "password": "password"}}';
var client = Titanium.Network.createHTTPClient({timeout: 10000});
client.cache = false;
client.open("POST", "http://"+hostName+":"+portNo+"/AccountCreate");
client.setRequestHeader("Content-Type", "application/json");
client.send(regDetails);
alert(JSON.parse(this.responseText));
});
can any one please.
I got the solution.
We need to use onload function. This will get the result from specified url:
My code is below: