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.

0 0 votes
Article Rating

Do you want to hire us for your Project Work? Then Contact US.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x