---
title: "使用jQuery ajaxfileupload.js 遇到的小问题"
author: "huttoncs"
date: "2016-04-12T16:31:55Z"
tags: []
categories: ["Web前端"]
slug: "jquery-ajaxfileupload-js"
draft: false
lastmod: "2016-04-12T16:31:55Z"
id: 2290297
url: "https://huttoncs.iteye.com/blog/2290297"
---

```
问题1：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：一直得到error ，无法执行指定的success方法。

```

文件正常提交，后台接收正常，action中返回json正常，用火狐查看，响应的值也是正常的

但是，ajax调用js中，就是不走success的方法。

经过调查，是因为返回的json中，带有&lt;pre&gt;标签。

修正方法：

ajaxfileupload.js文件，uploadHttpData中

  【eval( "data = " + data );】--&gt;【data = jQuery.parseJSON(jQuery(data).text());】

```

```