weixin_33676492 2016-10-19 04:44 采纳率: 0%
浏览 7

从AJAX附加img

I'm trying append <img> to a div using Ajax (because I need to fetch the name of image from database).

I already get the <img> tag on my div, also get the src attribute to the correct image. But I'm still not seeing the image. I'm just seeing a <img> tag with 0 x 0 size. Try to enlarge the size, still see nothing..

I try to open image via link that generated inside src attribute, and I can see the image that I want to append.. Why this is happen ?

This is my code

Trigger to function that contain ajax

<div class="HotelListDescriptionContent" onclick='showDetailRoom("<?php echo $arrayroomssearch[$arrk]['room_code']?>")'>

Function With Ajax

function showDetailRoom(roomid)
{
    if(j("#detailroom"+roomid).is(":visible"))
        j("#detailroom"+roomid).hide();
    else
    {
        j.post("inc/querys/roomdetail.php",
        { 
            roomid : roomid,
        },
        function(data){
            // console.log(data);
            j("#detailroom"+roomid).html("");
            // j("#detailroom"+roomid).append($("<option></option>").append("Select your state..."));
            if(data == "empty")
            {
                j("#detailroom"+roomid).append($("<option></option>").append("State Not Found..."));
            }
            else
            {
                j(data.photo).each(function(i,item){
                    // console.log(item);
                    j("#detailroom"+roomid).html("<img scr='<?php echo SITE_URL;?>upload_photos/images/"+item+"'/>");
                })
            }
            j("#detailroom"+roomid).show();
        },
        "json");
    }
}

Div target

<div id="detailroom<?php echo $arrayroomssearch[$arrk]['room_code'];?>" style="display:none;">

Div target (via Inspect Element)

<div id="detailroom20" style=""><img scr="http://localhost/bookingbeol/bk-admin/upload_photos/images/kamar3-1476346812.jpg"></div>

Div target not showing the image enter image description here

  • 写回答

1条回答 默认 最新

  • weixin_33711641 2016-10-19 04:49
    关注

    Got it-- you just mistyped it -- should be src not scr. Easy mistake to make-- difficult to see or notice when scanning or glancing over the code.

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)