Skip to content
Advertisement

ajax get data request url not found but already exist, Laravel 8

hello guys i have a problem with my ajax data json, i have a project about scan a barcode with a webcam but it just views the code of the barcode, the data in the database not call in my ajax, this is the code of blade, i’m using a modal this is the modal

JavaScript

this is the jquery code

JavaScript

this is the controller

JavaScript

this is the route

JavaScript

what should i do the error said “jquery.min.js:2 GET http://localhost:8080/rezkastore1/%7B%7B%20route(‘daftar_produk.scan’)%20%7D%7D?kode=2135758676 404 (Not Found)”

Advertisement

Answer

I have no idea wether you write your Javascript section, in Laravel Blade View or in separate JS file. If you write it within Laravel Blade Template, you may use

JavaScript

but I recommend you to write complete URL within your AJAX call. Make your AJAX call like this :

JavaScript

Instead of using findOrFail(), you can use find() or regular where() with error handler, because findOrFail() will returns 404 not found if it can’t find any records, here is the cekScan function

JavaScript

Maturnuwun

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement