钛 httpclient 异常错误请求
titanium httpclient exception bad request
这是我的代码,我要发送请求,url有用
var go_login;
go_login = function(e) {
var params, xhr;
xhr = Ti.Network.createHTTPClient();
xhr.open("post", Setting.server+"/interface/about_us");
xhr.onload = function() {
console.info(this.responseText);
if (this.status === "200") {
console.info("successful");
} else {
console.info(this.status + "--------------------" + this.response);
}
};
xhr.onerror = function(e) {
console.info(e.error);
};
params = {
mobile_phone: $.login_phone.value,
password: $.login_password.value
};
return xhr.send(params);
};
这是我的错误:
[ERROR] TiHttpClient: (TiHttpClient-1) [5706,6457] HTTP 错误 (org.apache.http.client.HttpResponseException): 错误请求
[ERROR] TiHttpClient: org.apache.http.client.HttpResponseException: 错误请求
[ERROR] TiHttpClient: 在 ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:275)
[ERROR] TiHttpClient: 在 ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:219)
[ERROR] TiHttpClient: 在 org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
[ERROR] TiHttpClient: 在 org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
[ERROR] TiHttpClient: 在 ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1329)
[ERROR] TiHttpClient: 在 java.lang.Thread.run(Thread.java:856)
我不知道为什么请求不好
我刚刚解决了这个问题,将"post"替换为"POST",然后就可以了
这是我的代码,我要发送请求,url有用
var go_login;
go_login = function(e) {
var params, xhr;
xhr = Ti.Network.createHTTPClient();
xhr.open("post", Setting.server+"/interface/about_us");
xhr.onload = function() {
console.info(this.responseText);
if (this.status === "200") {
console.info("successful");
} else {
console.info(this.status + "--------------------" + this.response);
}
};
xhr.onerror = function(e) {
console.info(e.error);
};
params = {
mobile_phone: $.login_phone.value,
password: $.login_password.value
};
return xhr.send(params);
};
这是我的错误:
[ERROR] TiHttpClient: (TiHttpClient-1) [5706,6457] HTTP 错误 (org.apache.http.client.HttpResponseException): 错误请求 [ERROR] TiHttpClient: org.apache.http.client.HttpResponseException: 错误请求 [ERROR] TiHttpClient: 在 ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:275) [ERROR] TiHttpClient: 在 ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:219) [ERROR] TiHttpClient: 在 org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) [ERROR] TiHttpClient: 在 org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) [ERROR] TiHttpClient: 在 ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1329) [ERROR] TiHttpClient: 在 java.lang.Thread.run(Thread.java:856)
我不知道为什么请求不好
我刚刚解决了这个问题,将"post"替换为"POST",然后就可以了