600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > js ajaxfileupload.js上传报错的操作【javascript】

js ajaxfileupload.js上传报错的操作【javascript】

时间:2024-08-21 20:00:17

相关推荐

js ajaxfileupload.js上传报错的操作【javascript】

web前端|js教程

js,ajaxfileupload.js,上传,报错

web前端-js教程

相信大家在工作中经常用到文件上传的操作,因为我是搞前端的,所以这里主要是介绍ajax在前端中的操作。代码我省略的比较多,直接拿js那里的

好用的新闻系统asp源码,修改ubuntu清华镜像,官网下载tomcat8,爬虫哪些网页简单,株洲php程序开发培训收费,小白影院seolzw

$.ajaxFileUpload({url:www.coding/mobi/file/uploadSingleFile.html,//处理图片脚本secureuri :false,fileElementId :image2,//file控件id。就是input type="file"dataType : json,success : function (data, status){ console.log(data);},error: function(data, status, e){ alert(e);}})

按照教学,这样子上传的话是没有问题的,可是它一直有一个报错。报的是什么错有点忘了,不好意思 ,因为用完很久才记得补回这篇文章,但是要修改它的源码,那个错误就可以解决了

268网校源码,ubuntu查看设备节点,python爬虫请求过快,php mysqlconn,胡鑫SEOlzw

它源码的最后一段是这样子的

phpcms v9 整站源码,vscode标签手册,ubuntu中tree的安装,tomcat 7 jsp,ruby sqlite3,js 编辑器插件,如何搭建vue前端框架,jsoup爬虫 付费文章,重复提交 php,黑帽seo团队,网站背景的动态线条怎么制作,易语言 与网页交互,信息版模板,jquery 页面载入,织梦内容管理系统文章编辑表格不见了边框线,微擎微信小程序怎么安装lzw

uploadHttpData: function( r, type ) { var data = !type; data = type == "xml" || data ? r.responseXML : r.responseText; // If the type is "script", eval it in global context if ( type == "script" ) jQuery.globalEval( data ); // Get the JavaScript object, if JSON is used. if ( type == "json" ) eval( "data = " + data ); // evaluate scripts within html if ( type == "html" ) jQuery("

").html(data).evalScripts(); //alert($(param, data).each(function(){alert($(this).attr(value));})); return data; }将这一段改为这样子

uploadHttpData: function( r, type ) { var data = !type; data = type == "xml" || data ? r.responseXML : r.responseText; // If the type is "script", eval it in global context if ( type == "script" ) jQuery.globalEval( data ); // Get the JavaScript object, if JSON is used. if ( type == "json" ){ // 因为json数据会被

标签包着,所以有问题,现在添加以下代码, // update by hzy var reg = /

(.+)/g; var result = data.match(reg); result = RegExp.$1; // update end data = $.parseJSON(result); // eval( "data = " + data ); // evaluate scripts within html } if ( type == "html" ) jQuery("

").html(data).evalScripts(); //alert($(param, data).each(function(){alert($(this).attr(value));})); return data; }这样就可以正常使用了。

另一种情况:ajaxFileUpload 报这错jQuery.handleError is not a function

版本1.4.2之前的版本才有handlerError方法,例子里使用的Jquery是1.2的,解决方法:

为了能够继续使用ajaxfileupload上传我们的附件,只好将下面代码拷进我们的项目中的ajaxfileupload.js文件中

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] ); } }

以上就是面对ajaxupload.js上传报错问题的解决方法,希望能帮助大家解决困难,也希望大家继续关注脚本之家更多精彩内容。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。