Jquery文件上传SyntaxError:JSON.parse:JSON数据后的意外的非空白字符 [英] Jquery File Upload SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

查看:2540
本文介绍了Jquery文件上传SyntaxError:JSON.parse:JSON数据后的意外的非空白字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSON数据后的意外的非空白字符

我想使用prduct,但上传图片时,我看到错误
$ b SyntaxError:JSON.parse:

 脚本目录:Folder2 
目录Jquery-file-upload:function / blueimp-jQuery-File-Upload /
in main.js我编辑行
$ b $('#fileupload')。fileupload({
//取消注释以下内容以发送跨域cookie:
/ / xhrFields:{withCredentials:true},
url:'server / php /'
});



 <$文件上传({
//取消注释以下内容以发送跨域cookie:
// xhrFields:{withCredentials:true},
url :'../function/blueimp-jQuery-File-Upload/server/php/'
});

图像真正保存在服务器上,但上传后显示错误。 b

Step1
http://s55.radikal.ru/i149/1211/10/8c8d911589de.jpg



Step2错误
http://s019.radikal.ru/i604/1211/8c/ 7e05d92b30ef.jpg



furebug回应请求

  [{ 名称: 1353755388.jpg, 大小:879394, 类型: 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的文件,Upload\ / server\ / php\ / files\ / thumbnail\ / 1353755388.jpg, upload_to_db:真, delete_url:HTTP:\ / \ /米alish-ka.ru\ / function\ / blueimp-jQuery的文件-Upload\ / server\ / php\ /文件= ExPRoG-1353755388.jpg, delete_type?: DELETE}] / home / m / malishkaru / public_html / function / blueimp-jQuery-File-Upload / server / php 

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

解决方案

您显示的对请求的响应

如果你可以改变你的PHP在关闭后没有返回任何东西],你将拥有有效的JSON。

删除零件代码时写入

/ home / m / malishkaru / public_html / function / blueimp-jQuery-File-Upload / server / php nnnnnn



用户 nnnnnn 给出很好的答案。

I want use prduct but when upload image i see error

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

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/'
});

on

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

Image true save on server, but error with show him after upload.

Step1 http://s55.radikal.ru/i149/1211/10/8c8d911589de.jpg

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

furebug response to a request

[{"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

Tell me please why i have this error? When error?

解决方案

The "response to a request" that you show is not valid JSON because of the text after the closing ].

If you can change your PHP to not return everything after the closing ] you'll have valid JSON.

The "unexpected non-whitespace character" is the / in /home/m/etc after the closing ]

I delete part code when write /home/m/malishkaru/public_html/function/blueimp-jQuery-File-Upload/server/php and all worked.

P.S.: thanks nnnnnn.

P.P.S.: answer for close question only. user nnnnnn give good answer.

这篇关于Jquery文件上传SyntaxError:JSON.parse:JSON数据后的意外的非空白字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆