How does js read the contents of an online .json file?

an online link to a .json file, can you read the content with js? Can a link like
such as http://119.23.29.40/test.json read out the content directly with js?
fileReader seems to only read the contents of blob objects or file objects, so how to read such links

-Update-
you can get the data with $.ajax () of jquery, but you need to configure some cross-domain parameters on nginx (because of cross-domain problems)

Mar.30,2021

homologous direct ajax can read


homologous so that you can read

        $.get("http://119.23.29.40/test.json",{},function(res){
            console.info(res);
        });

the solution is as follows:

< H1 > 1 homologous can be read directly < / H1 >

if http://119.23.29.40/test.json and js files are in the same domain, you can read

directly. < H1 > 2 different sources < / H1 > < H2 > (1) can I control the return header of http://119.23.29.40/test.json? The browser itself has some restrictions on cross-domain calls. If you need cross-domain calls, add the following http header: < / H2 >
Access-Control-Allow-Origin: http://foo.example
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: X-PINGOTHER
  1. Origin. The HTTP request header, which must be carried by any request involving CORS.
  2. Access-Control-Request-Method. HTTP request header, the method used to represent the real request in a cross-domain request with a pre-checked (Preflighted).
  3. Access-Control-Request-Headers. HTTP request header, which is used to represent the custom Header list of real requests in cross-domain requests with pre-checked (Preflighted).
  4. Access-Control-Allow-Origin. The HTTP response header, which specifies the source domain in which cross-domain resource access is allowed on the server side. You can use the wildcard character * to indicate that the JavaScript of any domain is allowed to access resources, but in response to a HTTP request with identity information (Credential), the Access-Control-Allow-Origin must specify a specific domain, not a wildcard.
  5. Access-Control-Allow-Methods. The HTTP response header, which specifies the list of request methods that the server allows access to cross-domain resources, which is generally used to respond to pre-check requests.
  6. Access-Control-Allow-Headers. HTTP response header, which specifies the list of request headers that the server is allowed to access cross-domain resources, which is generally used to respond to pre-check requests.
  7. Access-Control-Max-Age. The HTTP response header, which is used to respond to the pre-check request, indicates the validity time of the pre-check response. During this time, the browser can decide whether it is necessary to send the real request directly based on the result of the negotiation without sending the pre-check request again.
  8. Access-Control-Allow-Credentials. HTTP response header. The browser will ignore the response if the identity information is carried in the browser request and no Access-Control-Allow-Credentials: true is returned in the response header.
< H2 > (2) if you can't control it, you need to add a proxy server as a transit server (the nginx mentioned by the subject can also be used as a proxy transfer), and add a cross-domain header. < / H2 >

there is something the author has already done: https://www.npmjs.com/package.

< H1 > Summary < / H1 >

when you encounter a cross-domain problem, it involves the homologous policy restriction of the browser, which can be read directly from the same origin. Cross-domain headers need to be added for cross-domain. If you cannot control it, you can add transit server processing.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea1a22-47929.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea1a22-47929.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?