//异步上传文件,成功时,执行SuccessDo并返回1; //当失败时,返回JSON数据 // url:文件要上传的url // fileId:要上传的文件名 // 当上传文件成功时,执行ScuccessDo Function /// Ajax.FileUpload = function (url, fileId, SuccessDo) { var imageLoad; var imageLoadParent; var myform = document.createElement("form"); myform.style.display = "none"; myform.action = url; myform.enctype = "multipart/form-data"; myform.method = "post"; var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase()); if (is_chrome && document.getElementById(fileId).value == '') return; //Chrome bug onchange cancel if (document.all || is_chrome) {// IE imageLoad = document.getElementById(fileId); imageLoadParent = document.getElementById(fileId).parentNode; myform.appendChild(imageLoad); document.body.appendChild(myform); } else { //FF imageLoad = document.getElementById(fileId).cloneNode(true); myform.appendChild(imageLoad); document.body.appendChild(myform); } $(myform).ajaxSubmit({ success: function (responseText) { //这里请对应修改上传文件返回值,不要轻易把我删掉 var res = responseText.split('|'); alert(res[1]); if (res[0] == 1) { $(".k-close").click(); $(".k-window,.k-overlay").remove(); SuccessDo(); } } }); }