Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is my JSON file:

{"resource":"A","literals":["B","C","D"]}

This is the path of the JSON file: /Users/Documents/workspace/test.json.

I’ve saved these files in the local system and I want to create a JavaScript file to read the JSON file and print the data. Can anyone tell me how to do it? 

1 Answer

0 votes
by (19.7k points)

It’s not possible to make AJAX calls to local resources since the request is of HTTP type. What you can do it, run a local webserver, serve up the file and make AJAX calls to localhost. 

Check the code below to read JSON: 

jQuery.getJSON():

Refer to the documentation here

Interested in Java? Check out this Java tutorial by Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 17, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
asked Mar 25, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer

Browse Categories

...