下面是我返回的json对象。正如你所看到的,我有一个名为“DocumentVersions”的数组,其中包含要显示的文件的Blob地址。在成功函数上,我想在div下显示图像。我尝试循环但我不知道如何显示图像。我可以有多个文件返回。如何从包含数组的JSON对象显示文件?
{
"FileUploadID":"27",
"DocumentVersions":[
{
"Active":true,
"DocumentVersionID":"5",
"FileName":"Logo0112.png",
"ContentLength":18846,
"ContentType":"image/png", "
"RevisionNumber":0,
"RevisionDate":"2017-08-01T12:24:04.7748026+01:00",
"Blob":"https://address/documents/75755df4af5f.png",
"BlobFileName":75755df4af5f.png"
}
],
"success":true,
"id":"27",
"message":"The Files have been uploaded"
}
这是我的成功功能。从哪里获得“未定义‘一’不能读取属性”一滴
myDiv.on("complete", function (data) {
res = JSON.parse(data.xhr.responseText);
console.log(res);
if (res.success == true) {
for (var key in res) {
var optionhtml = '<p="' + res[key].FileUploadID +
'">' + res[key].DocumentVersions.Blob + '</p>';
$(".test").append(optionhtml);
}
}
else {
alert(res.message);
}
});
你可以发布你的代码jsfiddle吗? –