PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 12, 2022

[FIXED] How can I give laravel route in javascript attr()?

 January 12, 2022     javascript, laravel     No comments   

Issue

$('#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)}}

Solution

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);


Answered By - msk
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing