Home > Net >  How can I give laravel route in javascript attr()?
How can I give laravel route in javascript attr()?

Time:12-24

$('#formid').attr('action','table/' id);

I am using a form with form id 'formid' and 'id' is a variable containing id, this is the working code but I want to give route name instead of url , route is-

{{route('table.update',id)}}

CodePudding user response:

Just Do this

var url = '{{ route("table.update", ":id") }}';
url = url.replace(':id', id);

$('#formid').attr('action',url);

OR

    var url = "{{route('table.update', '')}}" "/" id;
$('#formid').attr('action',url);
  • Related