Laravel 8 Tutorial - Delete Record Using Ajax

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to the laravel air tutorial in this video we are going to learn about delete record using ajax last two video we have seen how to insert and update record using ajax now let's see how can we delete the record using ajax so for that switch to the project and just open student.blade.php file so just go inside the resources then views and from here just open a string dot dot php file and inside this table uh let's create a new link so just write here a tag href is equal to javascript column void and just add here 0 and here the button class so just write here class btn within tensor add here the text delete all right and now save this file and let's check so just refresh the page and you can see here the grid link all right now go to the student controller so just click on app http controllers and just open split controller and inside this controller let's create a function for deleting the record so just write here public function and function name let's say function name is delete student and here just pass a parameter dollar id and inside this just right here student is equal to the student column column find and just add here dollar id all right then the student just call the delete function so just write here arrow delete and now just return response response as a json so just write your json and add here an array inside this json and just right here set this arrow and here the message okay just right here record has been deleted all right now save this file and and let's create the route for this function so just go to the routes and just open web dot php and here just write route delete add here the uri as student slash just add here the parameter id then controller name and student controller column column class and here the function name which is uh this one deleted student so just copy and paste here now save this file now go to the student uh students dot students.php file and beside this file on the bottom let's create a javascript function so just right here script tag and inside this step tank just create a function here so just write here function and function name delete is student and just pass here the id inside this just idea if confirm add your message do you want do you really want to delete this record all right if yes then just call the hdx so just write here dollar as x and inside this just add here the url with url which is this one students and just pass here the id okay so just right here slash students and uh just right here concatenation sign id and here just type just right here type delete okay also add the data so just write your data and inside this just was it open token is equal to column sign dollar input name is equal to address form all right and just call here the val function and after this let's see if success and just add here a callback function and inside this response all right after our deletion just remove the table row deleted row so what is the id google row id id is is id and student id okay so removing the row just right here dollar s sid and just concatenate the student id okay so just write here id and call the remove function all right and now just call this function on button click so inside this delete button delete link just add here on a click and just paste here the function name delete student and inside this just pass here the student id just right here double curly bracket dollar is student arrow id all right now it's done so let's check this so switch to the browser and just refresh the page all right now let's delete this record so just click on this link do you really want to delete the record just click on ok and you can see record deleted okay now delete this record so just click on this delete button okay and record deleted all right so in this way you can delete the record using ajax in laravel 8 so that's all about delete record using ashx so thanks for watching this video and if you still have any kind of question you can ask me in the comment box don't forget to subscribe my channel thanks for watching
Info
Channel: Surfside Media
Views: 5,684
Rating: undefined out of 5
Keywords: How, to, Program, laravel (Software), laravel, laravel v8, laravel 8, laravel project, laravel setting up, laravel v8 setting up, laravel v8.0, v8.0, laravel 8.0, laravel 8 playlist, laravel 8 tutorial, laravel 8 lesson, laravel tutorial, laravel 8.0 tutorial for beginners, laravel for beginners, laravel tutorial for beginners, delete record using ajax in laravel 8, delete record using ajax in laravel, ajax crud in laravel 8, ajax, laravel 8 ajax crud, laravel8
Id: DhBCxUeGmm8
Channel Id: undefined
Length: 8min 18sec (498 seconds)
Published: Fri Sep 18 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.