百度UEditor组件出现Parameters: Invalid chunk '' ignored警告的分析

使用百度UEditor在线编辑器组件时,出现Parameters: Invalid chunk '' ignored的警告,之前的项目使用却没有,两个项目的环境应该是一样的。没有时间去对比两项目使用时到底环境有什么不同。直接想办法解决

网上搜寻下这个警告,有详细的说明,如:http://blog.csdn.net/lxy15329/article/details/5958837。后用ie的开发人员工具中的http请求捕获,发现有个请求:

js/ueditor/jsp/controller.jsp?action=config&&noCache=1408205227878

 

 

中间参数里有两个“&&”,正中了上面那篇博客里提到的一个原因。现在的问题就是找到是什么地方,什么时候发起的这个请求。

在ueditor.all.js中的8190行(蓝色行):

  var submitStr = json2str(ajaxOpts);  // { name:"Jim",city:"Beijing" } --> "name=Jim&city=Beijing"
        //如果用户直接通过data参数传递json对象过来,则也要将此json对象转化为字符串
        if (!utils.isEmptyObject(ajaxOpts.data)){
            submitStr += (submitStr? "&":"") + json2str(ajaxOpts.data);
        }
        //超时检测
        var timerID = setTimeout(function() {
            if (xhr.readyState != 4) {
                timeIsOut = true;
                xhr.abort();
                clearTimeout(timerID);
            }
        }, ajaxOpts.timeout);

        var method = ajaxOpts.method.toUpperCase();
        var str = url + (url.indexOf("?")==-1?"?":"&") + (method=="POST"?"":submitStr+ "&noCache=" + +new Date);
        xhr.open(method, str, ajaxOpts.async);

url里已经存储着:/js/ueditor/jsp/controller.jsp?action=config

调试运行时可以看到:method=“get”,submitSt=“”,这样就造成最后的结果是:

/js/ueditor/jsp/controller.jsp?action=config&&noCache=1408205227878

修改方法有多种,我是这样改的:

 xhr.open(method, str, ajaxOpts.async);   ----》 xhr.open(method, str.replace("&&","&"), ajaxOpts.async);

要修改ueditor.all.min.js,可以搜索“method.toUpperCase()”,

,y=f.method.toUpperCase(),u=a+(-1==a.indexOf("?")?"?":"&")+("POST"==y?"":h+"&noCache="+ +new Date);e.open(y,u,f.async);

将e.open(y,u,f.async); 改为e.open(y,u.replace("&&","&"),f.async);

需要注意的是ueditor.all.min.js文件很大,找个好的文本编辑器,如:editPlus

猜你喜欢

转载自blog.csdn.net/lanfeng330/article/details/38623655
今日推荐