---
title: "ajaxfileupload 报错handleError"
author: "yangjayup"
date: "2015-09-25T19:46:38Z"
tags: []
categories: ["Web前端"]
slug: "ajaxfileupload-handleerror"
draft: false
lastmod: "2015-09-25T19:46:38Z"
id: 2246251
url: "https://yangjayup.iteye.com/blog/2246251"
---

天在用ajaxfileupload时firebug报了一个“jQuery.handleError is not a function”的错误。因为在以前使用jQuery.form一直都没有出现过这个问题，我对比以前的项目才发现，在这个项目中使用的jQuery是1.10.2的版本，而以前是使用的1.4.2。度娘一番之后，找到解决办法：jQuery.handleError is not a function 报错原因是：  
handlerError只在jquery-1.4.2之前的版本中存在，jquery-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] );  
     }  
   },

 

后来发现又报个错SyntaxError: expected expression, got '&lt;'  查阅资料发现：

答案是：dataType参数一定要大写。如：dataType: 'HTML'。