我正在尝试进行多张图像上传,我在控制选项卡网络中获得了响应,并且都可以正常上传,但是一旦我想在控制台中使用响应将其打印为“未定义”
我来自网络的回复:
{"msg":"<div class=\"alert alert-success\"><i class=\"fa fa-check\"><\/i> The file 5ac6060c8fc14 (1).jpeg successfuly uploaded.<\/div>","all_images":[{"name":"5ac6060c8fc14 (1).jpeg","dir_name":"f1197245ac6060c8fc14 (1).jpeg"},{"name":"5ac6060c8fc14_1_192x192.jpeg","dir_name":"abf70115ac6060c8fc14_1_192x192.jpeg"},{"name":"5ac6060c8fc14_1_192x192.jpeg","dir_name":"8b2f2625ac6060c8fc14_1_192x192.jpeg"},{"name":"5ac6060c8fc14_1_192x192.jpeg","dir_name":"bb2d7165ac6060c8fc14_1_192x192.jpeg"},{"name":"5ac6060c8fc14.jpeg","dir_name":"b1538ee5ac6060c8fc14.jpeg"},{"name":"5ac6060c8fc14_1_192x192.jpeg","dir_name":"f73d4195ac6060c8fc14_1_192x192.jpeg"},{"name":"5ac6060c8fc14_1_192x192.jpeg","dir_name":"6a2a2c35ac6060c8fc14_1_192x192.jpeg"},{"name":"5ac6060c8fc14.jpeg","dir_name":"bfb8ac35ac6060c8fc14.jpeg"}]}
我的代码:
$('#upload_files').easyupload({
url: 'sources/requests/ajax.php?type=upload-files',
on_upload_before: function (info) {
$('#status_1_text').html('');
$('#progress_1').fadeIn(150);
$('#status_1,#status_1_total').css({width: 0});
},
on_progress: function (progress) {
$('#status_1').css({width: progress.progress_file + '%'});
$('#status_1_total').css({width: progress.progress_total + '%'});
$('#status_1_text').html('Sending files ' + progress.current_file +
' / ' + progress.total_files + ' ');
},
on_upload_file: function (data) {
$('#status_1').css({width: 0});
$('#status_1_text_total').html(data.msg)
$('#gallery').html(data.all_images)
},
on_upload_finish: function (data) {
console.log(data);
$('#progress_1').fadeOut(500);
$('#status_1_text_total').append('All files ' +
'successfully uploaded to the server.');
}
});
当我打印data.msg
时显示它但图像不起作用时,即使我写console.log(data);
其返回的undefined