1. 程式人生 > >用 ajaxFileUpload 出現的問題:has no method 'handleError'、返回json資料提示下載

用 ajaxFileUpload 出現的問題:has no method 'handleError'、返回json資料提示下載

1. 提示錯誤:Uncaught TypeError: Object function (a,b){return new d.fn.init(a,b,g)} has no method 'handleError'

目前找到兩種情況會出現這個錯誤:

(1)、url地址沒訪問到

(2)、$.ajaxFileUpload中的dataType的值為小寫,只需要把只該成大寫就ok了。比如dataType : 'JSON'

jQuery.handleError is not a function 原因是handlerError只在jquery-1.4.2之前的版本中存在,jquery-1.6 和1.7中都沒有這個函數了,因此在1.4.2中將這個函式複製到了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] );
		}
	},

2.返回json資料在ie下提示下載 

解決方法:

設定content-type為text/html或plain/text