bootstrap table导出功能无效报错Uncaught INVALID_CHARACTER_ERR: DOM Exception 5和导出中文乱码问题
由于表格数据中含有中文导致的,在网页的开发者选项中报一个 Uncaught INVALID_CHARACTER_ERR: DOM Exception 5 问题。这个问题是由于BootStrap table 默认不支持中文,只会识别 ASCII字符,为了让bootstrap table 识别出中文,我们需要扩展版的 jQuery.base64.js 插件,让其可以识别出unicode 字符。
解决该问题的方法时,将默认的jquery.base64.js 文件内容替换成下面提供的扩展版:
jQuery.base64 = (function($) { // private property
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; // private method for UTF-8 encoding
function utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
} function encode(input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = utf8Encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
keyStr.charAt(enc1) + keyStr.charAt(enc2) +
keyStr.charAt(enc3) + keyStr.charAt(enc4);
}
return output;
} return {
encode: function (str) {
return encode(str);
}
}; }(jQuery));
乱码问题(xml乱码)
待解决
bootstrap table导出功能无效报错Uncaught INVALID_CHARACTER_ERR: DOM Exception 5和导出中文乱码问题的更多相关文章
- xadmin后台导出时gunicorn报错ascii
django + xadmin + nginx + gunicorn部署后,xadmin后台导出model数据报错,gunicorn日志记录为:UnicodeEncodeError: 'ascii' ...
- 填坑——audio不能正常播放,控制台报错 Uncaught (in promise) DOMException
原文:https://blog.csdn.net/Mariosss/article/details/87861167 用chrome调试页面时,发现audio控件有时不能正常播放音频,控制台报错 Un ...
- jquery报错Uncaught ReferenceError: $ is not defined
- 后台返回json字符串 页面js报错 Uncaught SyntaxError: Unexpected identifier
后台json字符串是 [{"name": "报销申请", "id": "start"}, {"name&quo ...
- jquery使用ajax报错[Uncaught SyntaxError: Unexpected token :]
$.post('/ajax/validate.do',{"id": id},function(ret){ //ret }); 返回值明明是json,格式也是正确的,却解析不成功,在 ...
- jquery3.1.1报错Uncaught TypeError: a.indexOf is not a function
jquery3.1.1报错Uncaught TypeError: a.indexOf is not a function 使用1.9就没有问题,解决办法: 就是把写的代码中: $(window).lo ...
- jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function
jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function 使用.load()绑定事件时报错,Uncaught TypeError: e.i ...
- Vue. 之 报错 Uncaught (in promise)
Vue. 之 报错 Uncaught (in promise) 在点击同一个URL的时候,会报错如下: 解决方案: 在项目目录下运行 npm i vue-router@3.0 -S 即可.
- 网页视频不能自动播放?HTML5 video报错Uncaught (in promise) DOMException解决方法
话说发哥四年前写了一个网页,如上图效果,实际网址http://pano.z01.com ,话说做好时是正常的,突然某一天,客户说你这个网站动画不见了,这是什么原因? 结果检查脚本一切正常. 其实也不是 ...
随机推荐
- 几个优化SQL查询的方法
1.什么是执行计划 执行计划是数据库根据SQL语句和相关表的统计信息作出的一个查询方案,这个方案是由查询优化器自动分析产生的,比如一条SQL语句如果用来从一个 10万条记录的表中查1条记录,那查询优化 ...
- 洛谷p1732 活蹦乱跳的香穗子 二维DP
今天不BB了,直接帖原题吧 地址>>https://www.luogu.org/problem/show?pid=1732<< 题目描述 香穗子在田野上调蘑菇!她跳啊跳,发现 ...
- Qt实在太漂亮了
我很久之前就想用Qt,无奈对c++不熟悉,学习代价太大.想使用pyqt曲线救国,搞了好久的环境后放弃了.昨天又看了个很漂亮的qt例子,太漂亮了,让我很想进圈子.就从现在开始吧!!
- 4、Ansible(tags、roles)
Tags https://docs.ansible.com/ansible/latest/user_guide/playbooks_tags.html http://www.zsythink.net/ ...
- Python open 读写小栗子
1.样本内容 A.txt 2.上代码: f=open(r'E:\A.txt','r') boyA=[] boyB=[] count = for each_line in f: ]!='======': ...
- P4574 [CQOI2013]二进制A+B
传送门 思路: 本题可用数位DP来做,设 f [ i ][ a ][ b ][ c ][ j ] 表示当前枚举到(二进制下的)第i位,a' b' c'各用a,b,c了几个1,j表示最后一位是否有进位. ...
- curl: (6) Could not resolve host: www.baidu.com;
今天,在执行curl时,突然发现这个报错,问题是之前完全没有出现过这样的情况. [root@localhost ~]# curl www.baidu.comcurl: (6) Could not re ...
- Django本地开发,引用静态文件,火狐浏览器不能访问静态文件,谷歌浏览器却能访问静态文件
查了一下是settings.py设置问题 # Static files (CSS, JavaScript, Images)# https://docs.djangoproject.com/en/1.1 ...
- EndNote基础教程
endnote的使用方法 http://www.360doc.com/content/17/1211/08/31841004_711998509.shtml 导入文献 File-Import-Flod ...
- arcpy导入错误 问题 “ImportError: No module named arcpy”
如果阁下也出现如下图的错误,用本文的方法也许可以解决问题 首先,打开你python的安装位置,如下图所示的路径,找到desktop10.3.pth文件,打开查看,将你arcgis的相关路径,共3个绝对 ...