Host Operating System: OSX 10.9.1 Titanium studio :3.1.4.xxxxxxxx Simulator : IOS simulator
Hi I am beginner in Titanium. I have make demo application but I got Error for POST request to API.
I have got this issue in MAC OS but not found this issue in android application on windows7.
The Error given by request is: HTTP Error
Please find following code
function LoginServiceCall() { var strDeviceID = Titanium.Platform.id; var strDataToSend = '{"strAccountName": "xyz", "strPassword": "xyz", "strDeviceId" : ' + strDeviceID + '}'; var request = Titanium.Network.createHTTPClient(); request.onload = function() { var responseObj = JSON.parse(this.responseText); var responseLoginObj = JSON.stringify(responseObj.loginResponse); var responseObjData = JSON.parse(responseLoginObj); Ti.App.myGlobalVar = responseObjData.strToken; if (responseObjData.strToken != "") {//}&& !responseObj.tChangePassword) { Alloy.createController("changepassword", responseObjData.strLoginAccountName).getView().open(); $.index.close(); } }; request.onerror = function() { alert('Error while posting data'); }; request.open("POST", "http://xyz/pqr/ABCClient.svc/login"); request.setRequestHeader("Content-Type", "application/json; charset=utf-8"); request.send(strDataToSend); }
Please help to solve this issue.