小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

ajaxfileupload 異步上傳圖片返回?zé)o法進(jìn)入success,error

 瑤疏影 2016-02-16

ajaxfileupload 異步上傳返回?zé)o法進(jìn)入error,控制臺(tái)打印報(bào)錯(cuò)如下:

Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'handleError'

主要是jquery版本的問題,需要版本是1.4.2之前的jquery版本(解決方法請(qǐng)參看位于JQuery文件夾下的文章:ajaxFileUpload 報(bào)這錯(cuò)jQuery.handleError is not a function

后來通過想ajaxfileupload.js加入如下代碼解決

Js代碼  收藏代碼
  1. handleError: function( s, xhr, status, e ) {  
  2.     // If a local callback was specified, fire it  
  3.     if ( s.error ) {  
  4.         s.error.call( s.context || window, xhr, status, e );  
  5.     }  
  6.     // Fire the global callback  
  7.     if ( s.global ) {  
  8.         (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );  
  9.     }  
  10. },   
 

 

如果無法進(jìn)入success,看看是否是dataType 的類型返回不匹配

我遇到的情況是dataType='json';

后臺(tái)返回?cái)?shù)據(jù)代碼如下:

 

Java代碼  收藏代碼
  1. Gson gson = new Gson();  
  2.   
  3. Map map = new HashMap();  
  4.             map.put("photoId", photo.getPhotoId());  
  5.             map.put("photopath", TargetCommentsPhotopathHelper.getPhotopath_x200(photo.getPath()));  
  6.               
  7.             String gsonStr = gson.toJson(map);  
  8.             PrintWriter out = response.getWriter();  
  9.             out.print(gsonStr);  
 

這樣js會(huì)進(jìn)error,不進(jìn)success,主要是json返回的數(shù)據(jù)結(jié)構(gòu)不對(duì),可以讓返回正確結(jié)構(gòu)或修改dataType='text';再自行解析


以上來自:http://yangjayup./blog/1667094

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多