Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
113
rated 0 times [  118] [ 5]  / answers: 1 / hits: 15722  / 15 Years ago, mon, november 30, 2009, 12:00:00

I'm developing a simple JavaScript (jQuery) slide show. I wanted to use JSON to store some some static parameters about the content of each slide.



Since I like to keep my data separate from my code, is there anyway to have JavaScript evaluate a .json file?




  • AJAX seems a bit overkill - it just needs to evaluate it at run-time, nothing is dynamic.

  • I could have a separate .js file that holds my JSON data as an object - but this seems messy.



So before I use one of the above solutions, I just wanted to make sure there wasn't a cleaner way to have JavaScript evaluate a text file.


More From » json

 Answers
10

What's wrong with having a separate js file for your object? It has to live somewhere. I agree ajax is overkill, but I'm at a loss for why you think a JavaScript object in a .js file is messy.


[#98191] Wednesday, November 25, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calicinthias

Total Points: 447
Total Questions: 101
Total Answers: 118

Location: Botswana
Member since Sat, Dec 31, 2022
1 Year ago
calicinthias questions
Sun, Jan 2, 22, 00:00, 2 Years ago
Wed, Jan 13, 21, 00:00, 3 Years ago
Mon, Aug 10, 20, 00:00, 4 Years ago
;