How to pass link from controller to view in laravel on ajax call
How to pass link from controller to view in laravel on ajax call
Hello everyone, in this post we will examine how to solve the "How to pass link from controller to view in laravel on ajax call" programming puzzle.
You can pass link from controller to view in laravel using ajax call. You can get the URL link in controller using different method like route() and action() method which you want to send the view as an ajax response.-
Pass link from controller to view in laravel using ajax
//Create a route in web.php with name verification_link and after that call route method in controller and return to view using response()->json() method. $verificationLink = route('verification_link', ['phone' => $user->phonenumber]); return response()->json([ 'msg' => 'Please Verify your email first then login <a href="'. $verificationLink . '"> Verify Now </a>', ]); //Get the response from ajax using response.msg and append to html tag using jQuery .html() method. <div id="response"></div> <script> $.ajax({ url: form.action, type: form.method, data: $(form).serialize(), success: function(response) { $('#response').html(response.msg).show(); } }); </script>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Extract only time from datetime in laravel
- Class 'App\Providers\Auth' not found
- How to create projects method with belongstomany relationship in user model
- Generate random string lowercase in Laravel
- Retrieve count of nested relationship data in Laravel
- Target class [HomeController] does not exist
- Laravel csrf token mismatch for ajax POST Request
- External link not working in laravel blade
- How to add script on specific view file in laravel while extending layout
- Rendering HTML from database table to view in Laravel
- Store logged in user details in session and display in view in laravel
- How to check if user has created any post or not in laravel
- Laravel 7 login error message not showing
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- Laravel pagination links with query string
- How to validate form input data in laravel
- Get domain name in laravel
- Convert input array to comma-separated string in laravel controller
- Laravel form request validation
- Display first n record from collection in laravel view
- Pass variable from blade to controller Laravel
- How to get single column value in laravel
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- How to add foreign key in laravel using migration
- How to check email is valid or not in Laravel