一个上传的地方,
function upload_init(this_hour_num){
$('#hour_' + this_hour_num + ' .btn_upload').on({
click: function(){
$('#upload_tips').hide();
data_field = $(this).attr('data-field');
data_ex = $(this).attr('data-ex');
$item = $(this);
/*初始化上传按钮*/
$('#input_upload').uploadify({
"height" : 30,
"multi" : false,
"sizeLimit" : 500 * 1024 * 1024,
"swf" : "/Public/static/uploadify/uploadify.swf",
"fileObjName" : "download",
"buttonText" : "上传",
"uploader" : "/index.php?s=/course/upload/file_upload/savePath/" + data_field,
"width" : 120,
'removeTimeout' : 1,
'fileTypeExts' : data_ex,
"onUploadSuccess" : uploadSuccess,
'onFallback' : function() {
alert('未检测到兼容版本的Flash.');
}
});
/*上传成功后方法*/
function uploadSuccess(file, data) {
//document.write(data);
//var data = $.parseJSON(data);
var data = jQuery.parseJSON(data);
alert(data);
if(data.status == 'true') {
代码var data = jQuery.parseJSON(data); 这步出错。原因是多了一个不可见字符导致转码失败。 但是定位又找不到是哪里加的这个字符,所以请表格帮我写个正则,把这个过滤掉
我的想法是在jQuery.parseJSON(data);之前用正则,只取可见字符进行转码(只匹配下面那些就行,用不到的字符全部过滤掉)
大概涉及到的字符是这些:
?{"status":"true","info":{"name":"u4fe1u606fu5b89u5168u5e08u7406u8bbau8003u8bd5u590du4e60u9898(u6574u7406).pdf","type":"courseware","size":297069,"key":"download","ext":"pdf","md5":"cf18eb2947ec4fbad4b1c039f9673585","sha1":"281edac612317cdc8ea8b84ce55df1048a9a25f9","savename":"58c6550dbca94.pdf","savepath":"/Uploads/courseware/2017-03-13/","userid":false,"create_time":1489392909,"file_id":31476}}
js实在渣,写了半天写不对,不知道是写的代码有问题还是这样的思路不对。求表哥帮忙写一个
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…