Category : ajax

I am using laravel notifications and ajax to fetch all the notifications that belong to a user. However, I am not quick sure how to display the collection to the view. Here is an example, In user-notifications.blade.php: <li class="nav-item dropdown"> <a id="notificationBell" class="nav-link" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> <span class="fas fa-bell"></span> </a> <div class="dropdown-menu ..

Read more

I’m posting to api/record that’s suppose to catch validation errors in the JSON that I intentionally set: Vue Post Request this.$http({ method: ‘POST’, url: ‘api/record’, data: { emotions: [{‘id’: 1001, ‘intensity’: 20, ‘new_intensity’: 50}],//this.selectedEmotions, distortions: [{‘id’: 1001}],//this.selectedDistortions, situation: this.situation, } }) RecordController.php public function store(Request $request) { $this->validate($request, [ ‘situation’ => ‘required’, ]); $emotions = ..

Read more

I’m having this trouble with the ajax request. This code works on other pages, only on this not working. I want to call ajax (from different controller – CalendarController) on "show" page from controller ClientController – (http://…/client/35) maybe is that wrong Client.js $(document).ready(function() { $(‘#events-list’).on(‘click’, ‘.event-popup’, function () { var getEventId = $(this).data(‘id’); //this line ..

Read more

Using Laravel 5.4 I’m trying to submit a form with a file to upload with ajax. My jquery code: $("#uploadRoastsForm").submit(function() { var url = $(this).attr(‘action’); var fd = new FormData(); var files = $(‘#roastFile’)[0].files; if(files.length > 0) fd.append(‘file’, files[0]); fd.append(‘file’, files[0]); fd.append(‘roast_date’, $(‘#roastDate’).val()); $.ajax({ url: url, type: ‘POST’, data: fd, contentType: false, processData: false, success: ..

Read more

I have listing for users and a dropdown with state names for filtering users based on state through ajax. But when I show users after filter, action links are not working so I changed the code in controller as: public function statebasedusers(Request $request) { if($request->ajax()){ $search = User::where(‘state_name’,$request->statename)->get(); $output=""; foreach($search as $key => $value) { ..

Read more

I’m trying to check compability of my Laravel 8 project, I have datatables with route ajax: { url: "/detail/" + user_id, data: function(d) { d.kpi = $(‘#filter-kpi’).val(), d.search = $(‘input[type="search"]’).val() } }, when I acces it from artisan serve, it works pretty well (http://127.0.0.1:8000/detail/1000000004). But, when I access it using apache server in XAMPP (http://localhost/project-management-main/public/detail/1000000004), ..

Read more

I added a feature for user to be able to subscribe to a thread. So after subscribing the thread, I want to hide the subscribe button and show the unsubscribe button. show.blade.php: @if(auth()->check()) @if($subscription) <button class="btn btn-secondary" id="unsubscribe">Unsubscribe</button> @else <button class="btn btn-danger" id="subscribe">Subscribe</button> @endif @endif along with the ajax request: <script type="application/javascript"> $(document).ready(function(){ $(‘#subscribe’).click(function(e){ e.preventDefault(); ..

Read more

There is some data inside a table When I press the edit button, I can edit all the data for that row.Menu Category and Menu These two data came from Dependent dropdown. with this code the dropdown in the menu was supposed to show when the menu categories were selected. modal.find(‘.modal-body #menu_category_update’).val(menu_item_category_selected); modal.find(‘.modal-body #menu_update’).val(menu_item_selected); This ..

Read more

So I have an issue where I have an app.blade.php which acts as a master template. And a child template called show.blade.php. app.blade.php: <!doctype html> <html lang="{{ str_replace(‘_’, ‘-‘, app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!– CSRF Token –> <meta name="csrf-token" content="{{ csrf_token() }}"> <title>{{ config(‘app.name’, ‘Laravel’) }}</title> <!– Scripts –> <script ..

Read more

I have a button subscribe that should submit a post request via ajax to my controller for insertion to my table. This is how my view look like: @extends(‘layouts.app’) @section(‘content’) <div class="container"> <div class="row"> <div class="col-md-8"> <div class="flash-message"></div> <div class="card"> <div class="card-header"> <div class="level"> <span class="flex"><a href="{{route(‘profile’,$thread->creator->name)}}">{{$thread->creator->name}}</a> posted: {{$thread->title}} </span> @if(auth()->check()) @if($subscription) <button class="btn btn-secondary" ..

Read more

i am working on laravel web app to upload images into datatable and download that image on click it worked fine(( but i want the uploaded image to be downloaded on click ) until i change the code from return ‘{!! Html::link(‘images/u4.png’, ‘Download’) !!}’; to return ‘{!! Html::link(‘images/.$doc->image’, ‘Download’) !!}’; and the i am getting ..

Read more

I was searching stackoverflow for this issue but none of them worked. I have a subscribe button in my blade template where it is shown below along my ajax code: @extends(‘layouts.app’) @section(‘content’) <div class="container"> <div class="row"> <div class="col-md-8"> <div class="flash-message"></div> <div class="card"> <div class="card-header"> <div class="level"> <span class="flex"><a href="{{route(‘profile’,$thread->creator->name)}}">{{$thread->creator->name}}</a> posted: {{$thread->title}} </span> @if(auth()->check()) @if($subscription) <button ..

Read more

Everyone! I want to prevent the browser back button after submit post request in laravel 8. I followed tihs tutorial https://www.w3adda.com/blog/laravel-prevent-browser-back-button-after-logouttutorial public function handle($request, Closure $next) { $response = $next($request); return $response->header(‘Cache-Control’,’nocache, no-store, max-age=0, must-revalidate’) ->header(‘Pragma’,’no-cache’) ->header(‘Expires’,’Sat, 26 Jul 1997 05:00:00 GMT’); } But, It did not work. Can anyone tell me what is the ..

Read more

id = menu_selected_id sending each value by loop but when i receiving the data in HTML it just showing the first value. i think because of the unique id it happening My question is how can i make a unque id for this menu_id_selected in html and jquery $(document).ready(function() { $(‘select[name=”menu_item_category_selected”]’).on(‘change’, function() { var countryID ..

Read more

I am using ajax for showing doctor list in my index.blade.php file.But i want to show edit and delete button only for admin user rest users can not see the edit or delete button in index.blade.phpBut i dont understand who to do it on the following ajax portion. @section(‘js’) <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script> $(document).ready(function(){ fetch_doctor_data(); function ..

Read more

I want to make a try catch, when successful, the first condition appears with the message ok and if when it fails, the second condition appears with a message failed in Laravel But when executed when it is successful, it appears to the second state. $.ajax({ type: "POST", data: $(this).serialize(), url: "{{ route(‘tt.save’)}}", success: function ..

Read more

i have a problem in may controller for send 2 result to may ajax: $validData = $request->validate([ ‘id’ => "required" ]); $category_name = Category::where(‘parent’, $validData[‘id’])->pluck(‘name’); $category_id = Category::where(‘parent’, $validData[‘id’])->pluck(‘id’); return response($category_name , $category_id); how can send $category_name , $category_id ?? Sourc..

Read more