ajaxfileupload 异步上传图片返回无法进入success,error
ajaxfileupload 异步上传图片返回无法进入error,控制台打印报错如下:
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'handleError'
主要是jquery版本的问题,需要更高的jquery版本
后来通过想ajaxfileupload.js加入如下代码解决
handleError: function( s, xhr, status, e ) {
    // If a local callback was specified, fire it
    if ( s.error ) {
        s.error.call( s.context || window, xhr, status, e );
    }
    // Fire the global callback
    if ( s.global ) {
        (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
    }
}, 如果无法进入success,看看是否是dataType 的类型返回不匹配
我遇到的情况是dataType='json';
后台返回数据代码如下:
Gson gson = new Gson();
Map map = new HashMap();
            map.put("photoId", photo.getPhotoId());
            map.put("photopath", TargetCommentsPhotopathHelper.getPhotopath_x200(photo.getPath()));
            
            String gsonStr = gson.toJson(map);
            PrintWriter out = response.getWriter();
            out.print(gsonStr); 这样js会进error,不进success,主要是json返回的数据结构不对,可以让返回正确结构或修改dataType='text';再自行解析
相关推荐
  XuDTone    2015-04-07  
   ajaxyan    2013-09-12  
   yFifhting    2015-04-13  
   wujiajax    2015-04-10  
   dlcshjw    2019-04-19  
   XIAyuzheng    2018-08-23  
   wmsjlihuan    2019-04-14  
   maidou0    2015-03-10  
 为了美观,把 type="file" 控件隐藏。点击“上传”按钮,click调用隐藏文件控件,再选择文件。查了一遍,好像是ie为了安全控制,文件的必须鼠标点击过后,才能提交。还没有想到其他的方法。。。
  BluewineY    2013-06-17  
   kentrl    2018-08-23  
   dalong    2016-07-28  
 5,success 提交成功后自动执行的处理函数,参数data就是服务器返回的数据。6,error 提交失败自动执行的处理函数。7,data 自定义参数。fileElementId: 'file1',
  daydream000    2016-03-21  
   longshengguoji    2015-12-08  
   Ardencyz    2015-09-25  
   ghjcduhvfyjhbf    2015-09-24  
   learningever    2015-08-07  
   Balalala    2015-04-13  
   shumark    2015-04-10  
   shumark    2015-04-07  
 