pass the javascript value to the laravel value code example
Example: laravel variable in javascript
<script>
var data = {!! json_encode($data, JSON_HEX_TAG) !!};
</script>
<script>
var data = {!! json_encode($data, JSON_HEX_TAG) !!};
</script>