skip to Main Content
let name = $(this).attr("name");
let value = "{{ $response['" + name + "'] }}";

I am running this in $(document).ready()

2

Answers


  1. Your code shouldn’t work, because the php code will only be compiled first and then returned to the client(haha,That’s correct, right?);
    Let js receive php variable value in blade

    let value = `{{$a}}`;//`{{$a['hello']}}`
    
    Login or Signup to reply.
  2. Larvel has a helper to include json to be used in js https://laravel.com/docs/9.x/blade#rendering-json

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search