Skip to content
Advertisement

Setting ajax url in external js file in laravel 8

i have a single paged website developed in laravel 8 uploaded on a live server. The site has a contact form which uses ajax to send mail. Am currently having issues with setting the right ajax url. I have checked some solutions online but none have solved the problem.

Below are my routes.

JavaScript

On the blade header i have this:

JavaScript

Then in the external js file:

JavaScript

When i submit the form, it fails. Checking the browser console shows a “Not Found, The requested URL was not found on this server..” error. Any help is appreciated.

Advertisement

Answer

For starters, it looks like :

JavaScript

will generate a URL with a trailing slash at the end.

Then :

JavaScript

adds another trailing slash. Does your URL come out as https://www.baseurl.com//contactus by any chance?

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