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.

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button