2011年7月28日 星期四

Titanium post data to jsp

var xhr=Titanium.Network.createHTTPClient();    
xhr.open("POST","http://blah/blahblah.jsp");

//***** Don't set, otherwise can't send param successfully! ***
//xhr.setRequestHeader("content-type", "application/json"); 
xhr.send({"username":"idiot"});
xhr.onload = function(){
....  
};

NOTE: 
1. xhr.send({"username":"idiot"});
2. var dataStr = "{'username':'idiot'}"; 
   xhr.send(dataStr);
3. var dataParam = {"username":"idiot"};
   xhr.send(dataParam);


code {#1,#3} and #2 are different. #2 not work!

沒有留言:

張貼留言