Passing data from JS to Laravel

2020-02-15 javascript php html laravel

i have a parameter in my function JS .. The goal is when i click on my button the parameter should be assigned on new variable Laravel .. i want to pass my data from JS to Laravel

<script type="text/javascript"  >

    function change_theme(color) {

        {{ $idc = color }}//somthing like this 

        document.getElementById('iframe').setAttribute("src","{{(route('generate.pdfColor', ['slug' => 'student', 'id' => '56', 'color' => '$idc']))}}");
    }

</script>

Answers

<script type="text/javascript">
    function change_theme(color) {
    var url = "{{(route('generate.pdfColor', ['slug' => 'student', 'id' => '56', 'color' => ':id']))}}";
        url = url.replace('%3Aid',color);
        document.getElementById('iframe').setAttribute("src", url);
    }
</script>

Related