Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

laravel ajax post request

            let route = "{{ route('srcname') }}";
            let token = "{{ csrf_token()}}";
            $.ajax({
                url: route,
                type: 'POST',
                data: {
                    _token:token,
                    name:'name',
                    email:'email'
                    phone:'09876767'
               
                },
                success: function(response) {
                    console.log(response)

                },
                error: function(xhr) {
                    //Do Something to handle error
                }});

        }
        
        
        
        
        // laravel web
        Route::post('srcname', [Controllername::class, 'filter'])->name('srcname');
        
        // Controller
         public function filter(Request $request){ return $request->name ;}
        
        
        
        
 
PREVIOUS NEXT
Tagged: #laravel #ajax #post #request
ADD COMMENT
Topic
Name
5+9 =