skip to Main Content

I have created a html JS project.
I am calling AJAX function with URL but in the browser console, I see URL as Request URL: file:///C:/localhost:8080/allProducts

I want to call localhost:8080/allProducts

Code snippet:

$.ajax({
  url: '/localhost:8080/allProducts',
  ....
  ..

2

Answers


  1. You need to specify the protocol as in the following example:

    http:///localhost:8080/allProducts

    Login or Signup to reply.
  2. I would remove the localhost:8080 portion of the URL. Assuming allProducts is some sort of file in the root directory, I would put url: /allProducts.

    Then, if you end up pushing this into a production server it will look for allProducts at the root directory level, no matter the hostname.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search