L
L
lexstile2018-10-26 10:30:03
local server
lexstile, 2018-10-26 10:30:03

Can I make an ajax request to localhost?

Deployed a react project to localhost:8080.
There is a data.json file in the project root.
Can I make an ajax request to it? - if - yes,
how?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
Jupiter Max, 2018-10-26
@vardoLP

ajax request will somehow contact your server. But data.json is just data. If you need to pass them through ajax, see how it's done, you can here

D
dollar, 2018-10-26
@dollar

If everything is on the same domain (localhost), then why not?
There will be an error in the console if something goes wrong.
In extreme cases, you will have to configure the Access-Control-Allow-Origin header on the server.

I
Ihor Bratukh, 2018-11-25
@BRAGA96

import/require

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question