Jquery文件上载SyntaxError:JSON.parse:JSON数据之后的意外非空白字符

时间:2012-11-24 12:16:17

标签: php jquery file-upload

我想使用产品,但上传图片时我看到错误

SyntaxError:JSON.parse:JSON数据后出现意外的非空白字符

script directory: Folder2
directory Jquery-file-upload: function/blueimp-jQuery-File-Upload/
in main.js i edit rows

$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'server/php/'
});

$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: '../function/blueimp-jQuery-File-Upload/server/php/'
});

图片true保存在服务器上,但在上传后显示错误。

步骤1 http://s55.radikal.ru/i149/1211/10/8c8d911589de.jpg

Step2 with error http://s019.radikal.ru/i604/1211/8c/7e05d92b30ef.jpg

furebug对请求的回复

[{"name":"1353755388.jpg","size":879394,"type":"image\/jpeg","url":"http:\/\/malish-ka.ru\/function\/blueimp-jQuery-File-Upload\/server\/php\/files\/1353755388.jpg","thumbnail_url":"http:\/\/malish-ka.ru\/function\/blueimp-jQuery-File-Upload\/server\/php\/files\/thumbnail\/1353755388.jpg","upload_to_db":true,"delete_url":"http:\/\/malish-ka.ru\/function\/blueimp-jQuery-File-Upload\/server\/php\/?file=ExPRoG-1353755388.jpg","delete_type":"DELETE"}]/home/m/malishkaru/public_html/function/blueimp-jQuery-File-Upload/server/php

请告诉我为什么我有这个错误?出错时?

1 个答案:

答案 0 :(得分:3)

由于结束后的文字,您显示的“对请求的响应”无效JSON。

如果您可以将PHP更改为在结束后不返回所有内容,那么您将拥有有效的JSON。

“意外的非空白字符”是关闭后的/ in / home / m / etc

我在写 / home / m / malishkaru / public_html / function / blueimp-jQuery-File-Upload / server / php 时删除了部分代码,并且都有效。

P.S。:感谢 nnnnnn

P.P.S:仅回答密切问题。用户 nnnnnn 给出了很好的答案。