js图片上传失败提示错误
本帖最后由 omar111 于 2022-5-7 09:29 编辑报错信息
[*]{error: 0, data: "", extend: {…}}
[*]data:""
[*]error:0
xhr.onreadystatechange=function(){if(4==xhr.readyState){switch(xhr.status){case 200:var data={data};try{eval('data='+xhr.responseText);console.log(data);}catch(e){}
if(data&&data.error==0){$('#'+upfield).attr('src',data.extend.url).show();
$('#'+upfield+'1').attr('value',data.extend.url);
mui("#crop-dialog").popover("hide");callback&&window(data);}else{mui.toast(data.data);}
break;default:mui.toast('上传失败,请重试');break;}
that.removeAttr('disabled');}};xhr.send(formPost);});
$('#crop-plus-btn').off('click').on('click',function(){window.cropObject.zoom(0.1);});$('#crop-dec-btn').off('click').on('click',function(){window.cropObject.zoom(-0.1);});$('#crop-rotate-btn').off('click').on('click',function(){window.cropObject.rotate(90);});var fileElement=false;var getInputFile=function(attr,onChange){if(!fileElement){try{fileElement=$('<input accept="image/*" type="file" style="opacity: 0;" /'+'>');$(document.body).append(fileElement);fileElement.on('click',function(){fileElement.val('');}).on('change',onChange);}catch(e){alert(e.number+'-'+e.message+':'+e.descrption+'(创建INPUT=File失败)');}} <html>
<head>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<script>
$(function () {
$("#upload").bind("click", function () {
//var aa
var reader = new FileReader(); //创建读取对象
reader.readAsText($("#fileUpload").files); //读取文件
reader.onload = function (e) {
var aa = e.target.result;
alert(aa);
}
// alert(aa);
});
});
</script>
<input type="file" id="fileUpload" />
<input type="button" id="upload" value="Upload" />
</body>
</html>
页:
[1]