Reputation:
i want to insert image on page using javascript function
//JS
$('#fff').html('<img src="../images/pic.jpeg">');
when i write the url as above ...nothing loaded.
How can i write correct URL ?
Upvotes: 1
Views: 312
Reputation: 160833
If the js code is in your view template, then you do do
$('#fff').html('<?php echo image_tag('pic.jpeg') ?>');
else if it is in a separate js file, you need to use the absolute path for it.
$('#fff').html('<img src="/images/pic.jpeg">');
Upvotes: 2