Me and $ Not good friends, I do not know how to use this statement. Print all my data in my JSON file Another problem is that if the statement, I tried to do it in many ways, but who Even I did, no data is being printed.
My JSON file
[["expo": "Pete", "Datam": "05.06.2011 - 05.06.2016", "IMG": "Picture / "PTGhome.JPG", "link": "XP1_ index.html"}, {"Expo": "Space Odessy 2.0", "Datam": "17.02 - 09.05.2013", "IMG": "Picture / Such as .home.jpg "," link ":" exp2_index.html "}] my $ .getJSON script
& lt; Script type = "text / javascript" & gt; Function read_json () {$ .getJSON ("home.json", function) {var el = document.getElementById ("kome"); el.innerHTML = "& lt; td & gt; & lt; a href = "+ Data Link +" Data-ajax = 'False' & gt; & lt; img src = "+ data.img +" & gt; & lt; div class = 'dc' & gt; "+ data.expo + "<+++> Gt; ";}); } & Lt; / Script & gt; So how do I integrate $ .each statements and separate from that statement, if statement?
try it
$ GetJSON ("home.json", function) {var html = '', el = document.getElementById ("kome" $ .each (data, function (key, val) {html + = "& lt; td & Gt; & lt; a href = "+ val.link +" data-ajax = 'false' & gt; & lt; img src = "+ Val.img +" & gt; & lt; div class = 'dsc' & Gt; "+ val.expo +" & lt; br & gt; & lt; em> "+ val.datum +" & lt; / A & gt; & lt; / td & gt; ";}); el.innerHTML = html;});
No comments:
Post a Comment