简体   繁体   中英

Passing data from JS to 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>
<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM