我想使用HTTP请求发布JSON数据。我已阅读官方docs,我正在根据他们工作。我使用下面的代码:发布POST JSON数据Titanium
var xhrpost = Ti.Network.createHTTPClient();
xhrpost.onload = function(){
activityIndicator.hide();
alert('Posted successfully');
alert(JSON.stringify(this.responseText));
}
var posturl = 'http://qudova.com/api.php';
xhrpost.open('POST', posturl);
xhrpost.setRequestHeader("Content-Type", "application/json");
xhrpost.setRequestHeader('charset','utf-8');
var params = {
ProjectID : picked_prj,
RoleID : picked_rol,
FirstName: first.value,
LastName: last.value,
Phone: phone.value,
Email: email.value,
City: city.value,
State: stat_drp.getSelectedRow(0).title,
Zip: zip.value,
Notes: notes.value,
};
xhrpost.send(params);
如果这是张贴JSON数据的正确方法。我将如何检查数据张贴?该网址是否包含发布的数据?
我在onload事件中添加的以下警报中收到了空值。
alert(JSON.stringify(this.responseText));
我正在使用Windows 7,测试Android 4.2.2 ....在此先感谢。
不,这只是给我错误:未定义的对象。 – 2013-03-28 07:58:53