
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
- Insert values in pivot table dynamically in laravel
- How to get tomorrow and yesterday date in laravel
- Delete all related comments on deleting a post in Laravel
- Pass variable from blade to controller Laravel
- In order to use the Auth::routes() method, please install the laravel/ui package
- Display first n record from collection in laravel view
- Create records using relationship in laravel
- Post model with title and body in laravel 8
- Generate unique username in Laravel
- Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection refused)"
- How to get last record from object collection in laravel
- After image selected get validation error in laravel
- How to pass query string to url in laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- Eager loading dynamically in laravel
- Run artisan command to generate key in laravel
- Return view from route Laravel
- How to validate website url in laravel using validaiton
- Laravel order by date not working
- How to set column as primary key in Laravel model
- Get the post details if it has at least one comment in comments table
- How to get date from created_at field in laravel
- How to use or operator in laravel
- Permanently delete a record in laravel
- Laravel migration add foreign key to existing table