开发者

How to display the image which is not in current directory

开发者 https://www.devze.com 2023-03-10 11:28 出处:网络
I am using jquery to display results get by json object, here for image tag i used a hardcoded value.

I am using jquery to display results get by json object, here for image tag i used a hardcoded value.

$.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q=" + q + "&json.wrf=?", function(result) {
    $.each(result.response.docs, function(i, item) {
        html += "<br>UID_PK: =" + item.UID_PK;
        html += "<br>Name: =" + item.name;
        var src1 = "ABW0149_reg.jpg";
        html += "<img src=" + src1 + " />";
    });

    $("#result").html(html);
});

where "result" is a <div>

my problem is when i put ABW0149_reg.jpg in the same directory in which my this html file is it display the image but when i want to use image from some other path i do like this file:///E:/ABW0149_reg.jpg but开发者_开发百科 it does not display the image. Why is so, tell me how can i use image from some other source.


I think the issue here is that all modern browsers prohibit displaying local (file:///) images embedded in non-local (http://) pages.

It should work if you use some other remote path (like 192.168.1.10/images/image.jpg).


<img src="file:///..." /> actually tries to load image from client's hard drive.


Your images need to be within the same public-html/wwwroot.

You can then use relative addressing (eg ../image.jpg) or absolute(/folder/image.jpg).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号