Search
 
SCRIPT & CODE EXAMPLE
 

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 ;}
        
        
        
        
Comment

laravel ajax post data to controller

 $.ajax({
            url: "/route/to",
            type: 'POST',
            beforeSend: function (request) {
                return request.setRequestHeader('X-CSRF-Token', $("meta[name='csrf-token']").attr('content'));
            },
            success: data => {
                console.log(data);
            }
        });
Comment

PREVIOUS NEXT
Code Example
Javascript :: use of .json() in javascript 
Javascript :: closure in js 
Javascript :: on click copy text 
Javascript :: If statement discord js 
Javascript :: js get selected option element 
Javascript :: set attribute javascript 
Javascript :: body-parser deprecated 
Javascript :: How to access the GET parameters after “?” in Express 
Javascript :: socket io emit to socket id 
Javascript :: regular expression characters 
Javascript :: form.select not working react bootstrap 
Javascript :: socket.io how do i get a list of connected sockets clients 
Javascript :: javascript loop x times 
Javascript :: str replace javascript all 
Javascript :: usereducer react js 
Javascript :: linking html with javascript 
Javascript :: how to insert html into javascript 
Javascript :: encrypt decrypt in vanilla javascript 
Javascript :: convert Float64Array to array in js 
Javascript :: is jwt token expired 
Javascript :: export gcp credentials json file 
Javascript :: how to convert jsonobject to string in java 
Javascript :: JS toString adds backslash 
Javascript :: how to delete an element of an array in javascript 
Javascript :: jquery validation with ajax submit 
Javascript :: getmilliseconds javascript 
Javascript :: loadtest node 
Javascript :: javascript how to take off a decimal 
Javascript :: js unspecified parameters 
Javascript :: enviar formulario por ajax 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =