找回密码
 立即注册
收起左侧

QML XMLHttpRequest 请求有异别

2
回复
8347
查看
[复制链接]
累计签到:3 天
连续签到:1 天
来源: 2017-1-12 10:04:06 显示全部楼层 |阅读模式
5Qter豆
如果请求一个简单的文本,那么可以正常获取post内容


假如返回的文本很多了,就出现500的错误了。


怎么解决,能不能贴出代码呢!!是不是要c++ 和 qml配合

Version:1.0StartHTML:0000000107EndHTML:0000014315StartFragment:0000000471EndFragment:0000014277console.log("已经启动了");        var URL_Text_list = listurl;        var UserName_Text_list = listusername;        var PWD_Text_list = listpwd;        console.log(URL_Text_list);        console.log(UserName_Text_list);        console.log(PWD_Text_list);        var http = new XMLHttpRequest()        var url = "http://192.16.1.33/index.php/index/Start/startReplyMessage";        var params = "username="+PWD_Text_list+"&pwd="+UserName_Text_list + "&URL="+URL_Text_list;        http.open("POST", url, true);
        //Send the proper header information along with the request        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");        http.setRequestHeader("Content-length", params.length);        http.setRequestHeader("Connection", "close");
        http.onreadystatechange = function(e) {//Call a function when the state changes.            console.log(http.status);
            if(http.readyState == 4 && http.status == 200 ) {
                var object_Json = JSON.parse(http.responseText);
                for(var i in object_Json){
                    fruitModel.append(                                {
                                    "name":String(object_Json[i].record_name),                                    "cost":String(object_Json[i].body)                                }                                )                }
            }        }        http.send(params);ps:用curl 来请求数据,是可以的,应该php后台没关系的吧

回复

使用道具 举报

尚未签到

2017-1-14 00:43:13 显示全部楼层
试试用QNetworkAccessManager看看是不是也会这样错误
回复

使用道具 举报

累计签到:3 天
连续签到:1 天
2017-1-12 15:12:20 显示全部楼层
POST 真不行,于是用了GET 配合thinkphp 的URL访问参数,进行传递,终于可以了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了