Problems creating a POST in HTTPClient - mobile, android

I have been developing a mobile application and things were going well. I can download data from the server and render as needed.

I know need to grab a page from the web server. Modify the DOM and then post back the information. basically act as the browser but limit what the user may alter on the page. I have been able to get the page. Place in a DomDocument and alter the contents with the mobile UI.

Now in the onload of the first httpclient I want to create a second httpclient and send back the changes of the modified Dom as a POST. The HTTPClient is not even trying to connect to the server. I have a tunnel set up and no attempt to connect to the server is being made. Is it possible to new second HTTPClient in the onload section of first HTTPClient? Is this a known issue or is there some other way that I should be construction the post? Below is the section that is not working. I know there is an issue with reusing the HTTPClient to maintain cookies and headers and look forward to that being fixed.

It appears after a long timeout it does return a timeout. The readystate of the HTTPClient never gets past 1.


var xhr = Ti.Network.createHTTPClient();
xhr.onload = function()
// did some other code above this to get values
var xml = someDataAbove;

  submitButton.addEventListener ('click',function(buttonFunction){

    var xhr2 = Ti.Network.createHTTPClient();
    xhr2.onload = function()
    {'IN ONLOAD ' + this.status + ' readyState ' + this.readyState);
    var newWebPage = xhr2.responseText;"***newWebPage: "+newWebPage);

    xhr2.onerror = function(e)
    {'IN ERROR ' + e.error);



1 Answer

  • Try setting the content type:

    xhr2.setRequestHeader("Content-Type","text/xml; charset=utf-8");