0

Instead of fetching another file to load JSON data (local or remote), is it possible to just import the data into the HTML class?

The reason why I am asking this is because I would like to create 1 file that contains the HTML, CSS, JQuery, and JSON data without the browser having to fetch any other files.

Ideas?

2
  • <script></script> ... you will still need to load the jquery library Commented Mar 20, 2014 at 18:05
  • So what I did was copy the entire contents of jquery.js into the head of the HTML file. Commented Mar 20, 2014 at 19:16

1 Answer 1

1

You can simply put the data in a normal Javascript variable using an object literal.

var myData = { ... };
Sign up to request clarification or add additional context in comments.

2 Comments

But if you do this, could you access this JavaScript data from JQuery?
@JakeChasan: Yes; Javascript code can read Javascript variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.