我第一次学习javascript,并且有一些疑问:我有两个数组;第一个包含一个人的图像,第二个包含他的个人信息(数组的长度相同,因为它们包含相同数量的人)。我想写在我的网页上的内容,所以打印图像和第一位用户的信息,然后图像和第二等信息...使用javascript在我的页面中写入数组内容
我该怎么办?
这是代码:
function jsonCard()
{
var richiestaCard = new XMLHttpRequest();
richiestaCard.onreadystatechange = function()
{
if(richiestaCard.readyState == 4)
{
var objectcardjson = {};
window.arrayCard= []; //creazione dell'array che conterrà le cards
objectcardjson = JSON.parse(richiestaCard.responseText);
arrayCard = objectcardjson.cards; //the first array
}
}
richiestaCard.open("GET", "longanocard.json", true);
richiestaCard.send(null);
}
function jsonEntity()
{
var richiestaEntity = new XMLHttpRequest();
richiestaEntity.onreadystatechange = function()
{
if(richiestaEntity.readyState == 4)
{
var objectentityjson = {};
window.arrayEntity= []; //creazione dell'array che conterrà le entity
objectentityjson = JSON.parse(richiestaEntity.responseText);
arrayEntity = objectentityjson.cards; //the second array
}
}
richiestaEntity.open("GET", "longano.json", true);
richiestaEntity.send(null);
}
function displayArrayCards()
{
jsonCard();
jsonEntity();
var inizioTag = "<img src=";
var fineTag = "\>";
for(i = 0; i < arrayCard.length; i++)
{
...
}
}
我想有包含在该图像,然后将相关信息(第一用户),则图像和所有用于第二等等的相关信息DIV。
请显示您到目前为止的代码。 – nnnnnn
当这听起来完全类似于什么表时,您正在使用'div'的任何特定原因? –