brent400
brent400
  • 发布:2016-06-17 10:28
  • 更新:2016-06-17 11:36
  • 阅读:2210

IOS 网络请求数据量大约在200K报406

分类:HTML5+
 * Get 请求服务器  
     * @param {String} url 地址  
     * @param {JSON} data 数据JSON  
     * @param {Function} callback 回调函数 JSON对象  
     */  
app.get = function(type, url, callback) {  
        var t = null;  
        var xhr = new plus.net.XMLHttpRequest();  
        xhr.onreadystatechange = function() {  

            switch (xhr.readyState) {  
                //                  case 0:  
                //                      alert("xhr请求已初始化");  
                //                      break;  
                //                  case 1:  
                //                      alert("xhr请求已打开");  
                //                      break;  
                //                  case 2:  
                //                      alert("xhr请求已发送");  
                //                      break;  
                //                  case 3:  
                //                      alert("xhr请求已响应");  
                //                      break;  
                case 4:  
                alert(xhr.responseText);  
                    if (xhr.status == 200) {  
                        var result = null;  
                        if (xhr.responseText != undefined && xhr.responseText != "")  
                            result = app.getJSONObj(xhr.responseText);  
                        if (typeof callback == "function") {  
                            callback(result);  
                        }  
                    } else {  
                        alert("xhr请求失败:" + xhr.status);  
                    }  
                    break;  
                default:  
                    break;  
            }  
        }  
        if (type == "server")  
            url = app.getServerUrl(url);  
        if (type == "res")  
            url = app.getResUrl(url);  
        t = url;  

        xhr.open("GET", url);  
        xhr.send();  
    }  

xhr请求失败:406
求大神解决

2016-06-17 10:28 负责人:无 分享
已邀请:
DCloud_App_Array

DCloud_App_Array

请确认传输内容的字符集编码格式,并在http头中返回正确的content-type,如果没有返回正确的content-type,请使用overrideMimeType方法设置正确的字符集编码格式(charset=xxx),参考规范:
http://www.html5plus.org/doc/zh_cn/xhr.html#plus.net.XMLHttpRequest.overrideMimeType

该问题目前已经被锁定, 无法添加新回复