這是我的代碼,我想發出一個請求,網址是有用鈦HttpClient的異常錯誤的請求
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);
};
,這是我的錯誤:
[錯誤] TiHttpClient:(TiHttpClient-1 )[5706,6457] HTTP錯誤(org.apache.http.client.HttpResponseException):錯誤的請求 [錯誤] TiHttpClient:org.apache.http.client.HttpResponseException:錯誤的請求 [錯誤] TiHttpClient:at ti.modules .titanium.network.TiHTTPClient $ LocalResponseHandler.handleResponse(TiHTTPClient.java:275) [錯誤] TiHttpClient:at ti .modules.titanium.network.TiHTTPClient $ LocalResponseHandler.handleResponse(TiHTTPClient.java:219) [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) [錯誤] TiHttpClient:在ti.modules.titanium.network.TiHTTPClient $ ClientRunnable.run(TiHTTPClient.java:1329) [錯誤] TiHttpClient:在java.lang.Thread.run(Thread.java:856)
我不知道爲什麼錯誤的請求
將Setting.server +「/ interface/about_us」輸出到控制檯,並將其複製到設備瀏覽器中,網址是否正常工作? – Jeroen
我已經解決了這個問題,把「post」替換爲「POST」,然後它就起作用了 – wind