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
- Redirect to another view from controller in laravel
- How to create event and listener in laravel ?
- The POST method is not supported for this route. Supported methods: PUT.
- Where to use whereNotNull eloquent in laravel
- How to change default timestamp fields name in Laravel
- Print query in laravel
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- Show old value while editing the form in Laravel
- Laravel csrf token mismatch for ajax POST Request
- External link not working in laravel blade
- How to remove package from laravel
- How to add script on specific view file in laravel while extending layout
- How to Access Array in blade 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 create projects method with belongstomany relationship in user model
- How to create project_user pivot table in laravel
- How to get selected categories on edit record with Select2
- Laravel recursive function in controller
- Insert data with form validation using ajax in laravel
- Method Illuminate\Events\Dispatcher::fire does not exist
- Update last created record in Laravel
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- How to validate URL with https using regex in laravel
- Convert input array to comma-separated string in laravel controller
- Rendering HTML from database table to view in Laravel