You can use jQuery .getJSON() function:

$.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20%2a%20from%20yahoo.finance.quotes%20WHERE%20symbol%3D%27WRC%27&format=json&diagnostics=true&env=store://datatables.org/alltableswithkeys&callback', function(data) {
    // JSON result in `data` variable
});

If you don't want to use jQuery you should look at this answer for pure JS solution.

Answer from Dan Barzilay on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › how-to-read-json-file-in-javascript
How to Read a JSON File in JavaScript – Reading JSON in JS
November 7, 2024 - The only difference would be the URL. For example, suppose we have a local file within our project's folder named data.json that contains the following JSON data: <!--./data.JSON--> { "id": 1, "title": "Hello World", "completed": false } We can now read this file in JavaScript using the Fetch API method:
🌐
Educative
educative.io › answers › how-to-read-a-json-file-from-a-url-in-javascript
How to read a JSON file from a URL in JavaScript
An optional parameter that we sometimes ... loadJSON("https://jsonplaceholder.typicode.com/posts",myData,'jsonp'); Define the myData function. When data is read from the website, it is passed directly to the function myData...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › read-json-file-using-javascript
Read JSON File Using JavaScript - GeeksforGeeks
The fetch() API retrieves JSON files asynchronously and parses them into JavaScript objects. ... <html> <head></head> <body> <script> function fetchJSONData() { fetch('./sample.json') .then(response => { if (!response.ok) { throw new Error(`HTTP ...
Published   March 28, 2023
🌐
Oxylabs
oxylabs.io › blog › javascript-read-json-file
How to Read JSON Files in JavaScript: Tutorial
Using the Fetch API method, this JavaScript function retrieves a JSON file from a given URL. If the network response is successful, it parses data into a JSON string and displays the results using the displayProducts() method.
🌐
ZetCode
zetcode.com › javascript › jsonurl
JavaScript JSON from URL - Fetching Data Explained
Learn how to fetch JSON data from a URL in JavaScript using Fetch API, JQuery, and XMLHttpRequest, with examples and explanations.
🌐
ReqBin
reqbin.com › code › javascript › wc3qbk0b › javascript-fetch-json-example
How do I fetch JSON using JavaScript Fetch API?
... fetch('https://reqbin.com/... To automatically parse a JSON response into a JavaScript object, you need to use the response.json() method....
Find elsewhere
🌐
EyeHunts
tutorial.eyehunts.com › home › javascript read json file from url
JavaScript read JSON file from URL
June 1, 2023 - To read a JSON file from a URL using JavaScript, you can use the XMLHttpRequest or fetch API. Here's an example using both methods...
🌐
GitHub
gist.github.com › tomasevich › 5e42a97cab516f0792d46f68cd941c20
node js: read JSON file from URL like object · GitHub
var request = require ('request') request ({ url: 'https://raw.githubusercontent.com/rateljs/plugin/master/package.json', json: true }, (error, response, body) => { !error && response.statusCode === 200 ?
🌐
YouTube
youtube.com › watch
Web Basics - Accessing JSON data from URL - YouTube
This video shows how to access JSON data from a URL using JS and the JQuery resource
Published   December 13, 2019
Top answer
1 of 4
6

After so many months of search, I found the solution. Hence, I am answering my own question.

When JSON is not supported and when we are stuck with Same Origin Policy, we have to wrap around our JSON with a padding and make it a JSONP.

To do that, we have a life saving website http://anyorigin.com/

You can paste your URL and get the corresponding JQuery code something like this,

$.getJSON('http://anyorigin.com/get?url=http%3A//webapp.armadealo.com/home.json&callback=?', function(data){
$('#output').html(data.contents);
});

If you want to use your own code, then just use the URL from the code above, which is

http://anyorigin.com/get?url=http%3A//webapp.armadealo.com/home.json&callback=?

This above URL will give you the same JSON data as JSONP and solves all the trouble.

I had used the following code, which on success calls displayAll function

$.ajax({
        url: 'http://anyorigin.com/get?url=http%3A//webapp.armadealo.com/home.json&callback=?',
        type: 'GET',
        dataType: "json",
        success: displayAll
    });

function displayAll(data){
    alert(data);
}
2 of 4
5

If you look in Chrome inspector, you probably see this error:

XMLHttpRequest cannot load http://webapp.armadealo.com/home.json. Origin http://stackoverflow.com is not allowed by Access-Control-Allow-Origin.

What this means is that the server doesn't want the client web page reading the file. The client isn't trusted. This is a basic security feature of XMLHttpRequest in order to prevent a site like mybank.evil.com from downloading data from mybank.com. It unfortunately makes testing from a local file challenging.

If you trust any site with your data or a select number of sites, you can configure your server script to send the Access-Control-Allow-Origin to allow certain sites through.

See https://developer.mozilla.org/en/http_access_control for more details.

🌐
Rayobyte
rayobyte.com › blog › javascript-load-json-file-from-descktop
How to JavaScript Load JSON File From Desktop || Rayobyte
September 23, 2024 - When you do this, the fetch API will go to work. The JavaScript function retrieves the JSON file from the URL you provided to it. In situations where this is successful, the tool will then parse the data into a JSON string and display it.
🌐
Delft Stack
delftstack.com › home › howto › javascript › get json from url in javascript
How to Get JSON From URL in JavaScript | Delft Stack
February 2, 2024 - <!DOCTYPE html> <html> <head> <meta ... </body> </html> ... In this case, the fetch method simply takes the URL for allocating the data server and ensures to return the JSON data....
🌐
Linux Tip
linuxscrew.com › home › programming › javascript › how to read a local/remote json file in javascript [examples]
How to Read a Local/Remote JSON File in JavaScript [Examples]
November 28, 2021 - Above, fetch is used to retrieve the file at the given URL. The first then statement retrieves the JSON parsed version of the response. The second then statement then contains the parsed JSON file ready for use – in this case, it’s simply ...
🌐
Quora
quora.com › In-JavaScript-how-do-I-read-a-local-JSON-file
In JavaScript, how do I read a local JSON file? - Quora
Answer (1 of 13): It depends on what environment we're talking about. JavaScript now runs client- and server-side. Client side JavaScript is mostly found in browsers (Chrome, Firefox, Safari), and IE. Server side JavaScript is primarily nodejs. If you are talking about reading JSON from a local ...
🌐
CoreUI
coreui.io › answers › how-to-read-a-json-file-in-javascript
How to read a JSON file in JavaScript · CoreUI
December 3, 2025 - async function readJsonFile(filePath) ... error) }) This code uses fetch to retrieve the JSON file from the specified path, then calls the json() method which automatically parses the JSON content....
🌐
jQuery
api.jquery.com › jQuery.getJSON
jQuery.getJSON() | jQuery API Documentation
Most implementations will specify ... data, which is typically a JavaScript object or array as defined by the JSON structure and parsed using the $.parseJSON() method....