micky micky - 5 months ago 11
jQuery Question

Jquery image displaying


var res = $.parseJSON(data);

if(res.status == true)
var result = '<img src="{{asset('newuploads/+res.show.image+')}}"><br>'+
'Product Name:'+res.show.product_name+'<br>'+


Product Name and Price are displaying but not the image.
gives the proper image name but i am not being able to display the image.

In php, (laravel) this would do it :

<img src="{{asset("newuploads/{$show->image}")}}">


{{asset()}} isn't meant to be used dynamically by javascript. Unless you're using handlebars and wrote your own helper, asset() just resolves as / in your browser, so let's just do that:

'<img src="/newuploads/' + res.show.image + '"/>'

Which will produce the same result that you're attempting to achieve.