Laravel
Pass route naming in ajax url
In this article we will see how we can pass route naming in ajax url, i understood it’s been a bit difficult to send any parameter with the route naming in case of ajax. look for the below example.
id = $(this).attr('id'); var url = '{{ route("admin.task.delete", ":id") }}'; url = url.replace(':id',id); $.ajax({ type:"get", url: url, success: function(data) { swal("{{ __('tasks::lang.project-deleted') }}", { icon: "success", }); location.reload(); }, error: function(data) { swal("{{ __('tasks::lang.something-went-wrong') }}", { icon: "warning", }); }, });
I think by seeing above example you will understood how we can send it.