【发布时间】:2012-02-25 23:53:25
【问题描述】:
您好,我正在尝试使用 json 在钛中调用 webService。 该 webService 不接受任何参数,所以我只需要调用它。
这是我的代码:
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(10000);
xhr.open("POST","http://mytesturl.net/services/json/system.connect");
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhr.send();
xhr.onerror = function() {
Titanium.API.info("some thing is wrong in calling");
};
xhr.onload = function() {
Titanium.API.info("The API response is " + this.responseText);
};
在日志上我得到这个错误:
The API response is {"#error":true,"#data":"Invalid method ","#response_code":405}
我认为网址有误,但是当我尝试从终端调用相同的 Web 服务时,即使用 curl 实用程序
curl --data method=system.connect http://mytesturl.net/services/json
我得到了我需要的回应.. 我在这里做错了什么??
【问题讨论】:
标签: javascript json titanium appcelerator