Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm trying to route directly to the route with ajax in Laravel, but I'm getting an error

I’m trying to route directly to the route with ajax in Laravel, but I’m getting an error. I’m taking my first crack at Ajax with jQuery. I’m getting my data onto my page, but I’m having some trouble with the JSON data that is returned for Date data types. Basically, I’m getting a string back that looks like this: /Date(1224043200000)/ From someone totally new.

$(document).ready(function() {
        var delayInMilliseconds = 3000;
        var url = '{{ route('urun_durum_kontrolu') }}';
        var data = {
            "_token": '{{ csrf_token() }}',
        };
        setTimeout(function() {
            $.ajax({
                type: "post",
                url: url,
                data: data,
                success: function(response) {}
            });
        }, delayInMilliseconds);
    });

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

url = url.replace();

You need to use replace.

$(document).ready(function() {
            var delayInMilliseconds = 3000;
            var url = '{{ route('urun_durum_kontrolu') }}';
            url = url.replace();
            var data = {
                "_token": '{{ csrf_token() }}',
            };
            setTimeout(function() {
                $.ajax({
                    type: "post",
                    url: url,
                    data: data,
                    success: function(response) {}
                });
            }, delayInMilliseconds);
        });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading