0

I have a json file, that includes:

{
    "data": [{
        "red": "#f00",
        "green": "#0f0",
        "blue": "#00f",
        "cyan": "#0ff",
        "magenta": "#f0f",
        "yellow": "#ff0",
        "black": "#000"
    }]
}

And I want to put that data and alert it with a jquery code, the .json file is located on localhost in a neighbouring folder

0

2 Answers 2

0

This will load the data from the file

var jsonData = {};
$.getJSON('fileName',function(data){
    alert(JSON.stringify(data));
    jsonData = data;
});
Sign up to request clarification or add additional context in comments.

1 Comment

It works, but it puts the whole data with "{[{}]}"etc, into the variable too, and I have to put that into a html table, like an array. (with mustache.js)
0

Try this:

$.getJSON( json path, function( data ) {
    alert(data);
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.