kskaradzinski
kskaradzinski

Reputation: 5084

jquery after changing img src image is not showing

I have such code

<script type="text/javascript">
function openModal(title, id)
{
    $('#bookId').val($(this).data('id'));
    $('#modal h3').text(title);
    var d = new Date();
    $('#modal img').attr('src', '/media/upload/adv_baner/'+ id +'?'+d.getTime());
    $('#modal').modal('show');
}
</script>
<div id="modal" class="modal hide fade">
    <div class="modal-header">
        <a href="#" class="close" data-dismiss="modal">×</a>
        <h3>Modal header</h3>
    </div>
    <div class="modal-body" style="text-align:center">
        <p>
            <ul class="thumbnails">
                <li class="span3">
                    <img src="http://placehold.it/300&text=placehold.it+rocks!" alt="">
                </li>
            </ul>
        </p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn btn-danger">Delete</a>
    </div>
</div>

I want to pass id of an image like 29.jpg on my localhost it works great, but when I upload my files to my FTP it stopped working, but when i check the source code src is changed to one i pass as function parameter. I have checked my chmod and even set all on 777 but still image doesn't show.

Upvotes: 1

Views: 1583

Answers (1)

Imad
Imad

Reputation: 41

I think the error at here:

$('#modal img').attr('src', '/media/upload/adv_baner/'+ id +'?'+d.getTime());
  1. can we know the extension of this file & the extension of the image?

  2. At this time try this:

    $('#modal img').attr('src', 'media/upload/adv_baner/'+ id +'?'+d.getTime());
    

    or

    $('#modal img').attr('src', '../media/upload/adv_baner/'+ id +'?'+d.getTime());
    

Upvotes: 1

Related Questions