javascript - retrieving image from database with ajax append in Laravel 5.4 -




i using ajax request data database. append every data div. having problem in image source. put image files in public folder name image_files. problem retrieving image thru source , con-cat image filename database in ajax

here code:

function getproducts(category_id) {     $("#product-list").empty();     $.ajax({         url:"{{ url('product') }}/" +category_id,                 type:"get",         datatype: "json",                     success: function(data) {                 if(data.length>0) {                     for(i=0;i<data.length;i++) {                                                 $('#product-list').append('<div class="col-md-3 col-sm-3 hero-feature">'+'<div class="thumbnail">'+'<img src="{{ asset('image_files/' . '+data[i]['featured_img']+') }}" alt="">'+'</div>')                     }                 }             }             });         } 

my problem part:

<div class="thumbnail">'+'<img src="{{ asset('image_files/' . '+data[i]['featured_img']+') }}" alt="">'+'</div>' 

please help.

the code inside {{}} evaluated system variables laravel, , cannot mix javascript inside it.

$('#product-list').append('<div class="col-md-3 col-sm-3 hero-feature"><div class="thumbnail"><img src="{{ url('image_files/') }} ' + data[i]['featured_img'] +'" alt=""></div>'); 

that should trick, or atleast put on right path.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -