Home > Blockchain >  use laravel veriable in Jquery Image Slug
use laravel veriable in Jquery Image Slug

Time:12-09

I HAVE Image Slug Like:

url({{asset('landingpage/slider_images')}}/{{$img->slider_img}})

And I want to to use in this in following Jquery

$(function(){

    var fadeShow = $(".background").fadeShow({

        shuffle: true,

        speed: 5000,

        images: ['{{asset('landingpage/slider_images')}}/{{$img->slider_img}}']

    });

});

But its Not working for Me it returns the following error

enter image description here

CodePudding user response:

The error says it all. The thing you're trying to use ($img) is undefined. If you are not retrieving it in your blade view, in some way, then ensuring that it is being passed to the blade view (as $img) in your controller.

CodePudding user response:

I highly recommended to do it like that

balde :

<span id="slider_img" style='display:none;'> {{ $img->slider_img ?? "" }} </>

js :

$(function(){

    var fadeShow = $(".background").fadeShow({

        shuffle: true,

        speed: 5000,

        images: ['{{asset('landingpage/slider_images')}}/' $('#slider_img').text()]

    });

});
  • Related