gpt4 book ai didi

android - Titanium android 设备 http 错误

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:23 25 4
gpt4 key购买 nike

我在使用 Titanium 与网络中的服务器通信时遇到问题,服务器的 ip 是端口 8000 上的 192.168.0.208(是 Node.js 服务器)。如果我从浏览器调用服务器没有问题,但如果我尝试从 Titanium 中的应用程序调用服务器,我会看到此错误“目标服务器未能响应”并且在服务器日志中没有收到任何调用

这是我在应用程序中的 network.js 文件

    function HttpRequest(url, type, args, functionOnSuccss,functionOnError,timeout) {
// args is json parameters OPTIONAL
Ti.API.log("[HTTP REQ] Call" + url);

// ---# ok string ------
var xhr = Titanium.Network.createHTTPClient();
xhr.open(type,url);
xhr.cache = false;
xhr.enableKeepAlive = false;
xhr.timeout = timeout ? timeout : 500000;
xhr.setRequestHeader("Content-type", "application/json");
// xhr.setRequestHeader("Cookie", 'JSESSIONID=' + cookie + '');

xhr.onload = function(e) {

Ti.API.info("[HTTP] Response" + this.responseText);

functionOnSuccss(this.responseText);

};

xhr.onerror = function(e) {
Ti.API.info("ERROR " + e.error);
// alert("Connection Error");
functionOnError(e.error);
};
if(args){
xhr.send(args);
}else{
xhr.send();
}
};

exports.request = HttpRequest;

这是发出请求的尾声

network = require('/library/network');
var sendCarrello = function() {
$.loader.visible = true;
$.carrelloCamminante.animate(a);
url = "192.168.0.208:8000/newMobileUser"; // or http://192.168.0.208:8000/newMobileUser it's the same
network.request(url, "get",undefined, function(resp) {
alert(resp);
$.loader.visible = false;
}, function(err) {
alert("error - "+""+err);
});
};

可能是什么错误?

最佳答案

您必须使用“GET”而不是“get”:

network.request(url, "GET",undefined, function(resp) { ....

关于android - Titanium android 设备 http 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21856703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com