Saturday, 17 August 2013

how to load json in file into variable

how to load json in file into variable

I have a file.json with contents:
{
"a":{"var1":"Sábado"},
"b":{"var2":"Domingo"}
}
Having in mind that I cannot edit file.js, I need to figure out a way to
load the json contained in that file into a variable mj, so that
alert(mj["a"].var1) shows me the message Sábado.
UPDATE: Is this possible to accomplish without using JQuery, Prototype, or
any other js library?

No comments:

Post a Comment