百度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

 

posted @ 2016-04-07 09:01  lcchuguo  阅读(1160)  评论(0编辑  收藏  举报