user1435539
user1435539

Reputation:

In Symfony how can i write images url inside javascript

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

Answers (1)

xdazz
xdazz

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

Related Questions