ajaxFileUpload报错jQuery.handleError is not a function

本文介绍了解决AjaxFileUpload在使用新版jQuery时遇到的handleError方法缺失问题的方法。通过在AjaxFileUpload.js中手动添加handleError方法,可以确保文件上传功能正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

第一次使用ajaxFileUpload,据说,当年使用的jQuery还是1.9,好多年没更新了,而我。。。第一次使用jQuery就4.0了。

出现这个错误的原因是ajaxfileupload内部少了handleError方法,这个方法应该是jQuery版本里面的。So,copy一份过来ajaxfileupload.js内。

如下面红色部分是copy进来的,即在ajaxfileupload内如下添加红色部分

 
 
// JavaScript Document
jQuery.extend({
//添加内容↓
            handleError : function(s, xhr, status, e) {
                // If a local callback was specified, fire it
                if (s.error) {
                    s.error.call(s.context || s, xhr, status, e);
                }
 
                // Fire the global callback
                if (s.global) {
                    (s.context ? jQuery(s.context) : jQuery.event).trigger(
                            "ajaxError", [ xhr, s, e ]);
                }
            },
//添加内容↑
            createUploadIframe :function(id, uri) {
                // create frame
                var frameId ='jUploadFrame' + id;
 
                if (window.ActiveXObject) {
                    var io = document.createElement('<iframe id="' + frameId
                            +'" name="' + frameId + '" />');
                    if (typeof uri =='boolean') {
                        io.src ='javascript:false';
                    }elseif (typeof uri =='string') {
                        io.src = uri;
                    }
                }else {
                    var io = document.createElement('iframe');
                    io.id = frameId;
                    io.name = frameId;
                }
                io.style.position ='absolute';
                io.style.top ='-1000px';
                io.style.left ='-1000px';
 
                document.body.appendChild(io);
 
                return io;
            },
 

 

 

参考链接:http://zhangzhaoaaa.iteye.com/blog/2123021

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值