javascript - Cannot load the image using json data -
javascript - Cannot load the image using json data -
for (var = 0; < len; i++) { if (data[i].productid && data[i].name && data[i].shortdescription && data[i].mediumimage && data[i].price && data[i].iconimage) { alert(data) //var date = new date(parseint(data[i].date.substr(6))); var photoq = "../images/homeimages/" + data[i].mediumimage; alert(photoq); //<img id="imgad" src="/images/homeimages/1.jpg" width="181px" height="215px" alt="img"> var photo = "<img id='imgad' src='" + photoq + "' width='181px' height='215px' alt='img'/>"; alert(photo); txt += '<tr><td><div id ="result1" ><div>' + photo + '</div> <div ><div>' + data[i].productid + "</br> name- " + data[i].name + "</br> description " + data[i].shortdescription + ", </br>" + data[i].price + "</br>"; } } if (txt != "") { $("#table").append(txt); }
i getting name of image in alert image not rendering. used same procedure project , worked there. don't know why not working here.
your src should be:
var photoq = "/images/homeimages/" + data[i].mediumimage;
/images/homeimages/..
absolute path. means resource searched starting server's root. using /file.jpg
means searching straight in server's root.
when not using leading slash means have relative path. starting current directory in file scheme next path. ../
means looking in parent directory.
javascript jquery html html5
Comments
Post a Comment