B
B
basliney2021-11-23 23:53:43
JavaScript
basliney, 2021-11-23 23:53:43

How to pull xml or json into js from the same directory?

Good day. The question seems to be insanely simple, but managed to drive me into a dead end.
There is a gitlab project - ala tests for students. The bottom line is that questions and answers are stored in an xml or json file, and when choosing a test, the corresponding questions are loaded. When trying to implement methods for loading an xml or json file into the js code, the console threw an error about violation of the CORS policy, which, in principle, is both logical and not. The json file itself is in the same directory as the .js file
. Can you please tell me how to fix this? Maybe there are some methods other than raising the server?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2021-11-24
@402d

There are no directories on the Internet. there is a URI or a special case of a URL (http / https)
since the question does not have a NODE.JS tag, I assume by default that javascript is executed on the computer of the website visitor, and the files are hosted.

B
basliney, 2021-12-05
@basliney

61ad22336396e974181567.png
Here is such a structure, you need to pull up either questions.json or questions.xml. How to implement it correctly?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question