Read Json File Data Using Javascript?
function uploadJsonFunction(){ var jsonURL = 'C:\Users\My Documents\new\WebContent\JsonFiles\TreeJson\countries.json'; } countries.json is valid json and the above path has cou
Solution 1:
$.ajax({
url: "\countries.json",
success: function (data) {
var obj = JSON.parse(data);
}
});
For safety reasons, The C:\Users\My Documents\new\WebContent\JsonFiles\TreeJson\countries.json
url won't work in a browser.
Solution 2:
Solution 3:
Why not to try Google: http://www.json.org/js.html
I used this for Android app that worked with PhoneGap(HTML+Javascript+JQuery)
Worked fine.
My Method:
var link_name = pathtojson.json
$.getJSON(link_name,
function(data){
var ttext = (data["SearchResponse"]["Translation"]["Results"][0]["TranslatedTerm"]);
document.getElementById('ttexti').innerHTML = ttext;
}
);
Post a Comment for "Read Json File Data Using Javascript?"