$("#upload_file").change(function(){ UploadImg(); }); UploadImg = function() { $(window).bind('beforeunload',function(){return '正在上传,确定离开此页面吗?';}); $('#loading').attr('style','display:block;') $.ajaxFileUpload({ url:'upload_ajax.php', secureuri:false, fileElementId:'upload_file', dataType: 'text', success: function(data) { $('#loading').attr('style','display:none;'); if(data == 0){ $("body").overhang({ type: "error", message: "上传失败,CODE:00020" }); } else if(data == 1){ $("body").overhang({ type: "success", message: "上传成功!" }); setTimeout(function(){ window.location.reload(); },1000); } else{ $("body").overhang({ type: "error", message: "格式错误,仅支持jpg,png,gif" }); } $(window).unbind('beforeunload'); $("#upload_file").change(function () { UploadImg(); }); }, error:function(data,status,e){ $("body").overhang({ type: "error", message: "上传失败,CODE:00031" }); } }) }
AjaxFileUpload.js实现异步上传文件功能(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/66972339cd9aa41176c73dc9de2b9f34.html