【发布时间】:2014-04-25 14:34:58
【问题描述】:
描述:我想通过 POST 请求连接到服务器。我的方法,发布请求:
function loginClick(e) {
var url = "http://...";
var xhr = Ti.Network.createHTTPClient({
onload: function (e) { // this function is called when data is returned from the server and available for use
// this.responseText holds the raw text return of the message (used for text/JSON)
// this.responseXML holds any returned XML (including SOAP)
// this.responseData holds any returned binary data
Ti.API.debug(this.responseText);
alert(xhr.responseText);
},
onerror: function (e) { // this function is called when an error occurs, including a timeout
Ti.API.debug(e.error);
alert(e.toString);
},
timeout: 5000 /* in milliseconds */
});
xhr.autoEncodeUrl = false;
var params = {
email: $.email.value,
password: $.password.value
};
xhr.open('POST', url);
xhr.send(params); // request is actually sent with this statement
Ti.API.info(xhr.responseText);
};
但我不能这样做,因为收到奇怪的消息。我把它放在日志中。此外,我做了另一个请求,他们成功地工作了。 日志:
[ERROR] : TiHttpClient: (TiHttpClient-1) [3529,3529] HTTP Error (org.apache.http.client.HttpResponseException): Not Found
[ERROR] : TiHttpClient: org.apache.http.client.HttpResponseException: Not Found
[ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:258)
[ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:217)
[ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
[ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
[ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1287)
[ERROR] : TiHttpClient: at java.lang.Thread.run(Thread.java:841)
【问题讨论】:
标签: android rest titanium androidhttpclient