我正在尝试使用blueimp的文件上传功能,并且像很多人一样 - 我无法弄清楚为什么完成的回调不起作用!jQuery-File-Upload done回调
即使失败回调发送失败问题,文件上传也能正常工作(我使用php上传处理程序)。我已经阅读了很多关于json问题的主题,但没有回答符合我的问题。
这里是我的javascript代码:
$(function() {
'use strict';
var url = 'server/php/';
$('#fileupload').fileupload({
url: url,
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo('#files');
});
},
fail: function (data) {
alert("Fail!");
},
progressall: function (e, data) {
var progress = parseInt(data.loaded/data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
你有一个解决方案或某事进行测试,以发现一些错误?
EDIT1:成功的回调只能当我使用dataType: 'text'
EDIT2:这里是当完整的触发回调响应:
{"readyState":4,"responseText":"
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload- image/server/php/UploadHandler.php on line 299
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 780
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 804
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 806
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 809
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 812
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 815
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 819
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 822
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 826
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 832
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 885
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 905
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 963
\n
\nWarning: Unexpected character in input: '\\' (ASCII=92) state=1 in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 1048
\n
\nWarning: Cannot modify header information - headers already sent by (output started at /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php:299) in /home/mesdevis/work/SITE/acces_web/inner/upload-image/server/php/UploadHandler.php on line 1120
\n{\"files\": [{\"name\":\"IMG_0060.jpg\",\"size\":55277,\"type\":\"image\\/jpeg\",\"url\":\"http:\\/\\/[email protected]\\/SITE\\/acces_web\\/inner\\/upload-image\\/server\\/php\\/files\\/IMG_0060.jpg\",\"thumbnailUrl\":\"http:\\/\\/[email protected]\\/SITE\\/acces_web\\/inner\\/upload-image\\/server\\/php\\/files\\/thumbnail\\/IMG_0060.jpg\",\"deleteUrl\":\"http:\\/\\/[email protected]\\/SITE\\/acces_web\\/inner\\/upload-image\\/server\\/php\\/?file=IMG_0060.jpg\",\"deleteType\":\"DELETE\"}]}","status":200,"statusText":"OK"}
谢谢你的帮助,但那不是有效的。 – wilfryed 2015-02-09 13:52:11