javascript - Trying to populate using JSON, it is not working -
I want to populate a UL with a set of options using JSON.
JSON: My HTML code: My script: Pre> However, it is not working, the mistake is probably in the script what is wrong with it and How can I fix this? What do I need: Now what do I know: 'Options' is also a loop, but how do I create a loop inside a loop with JSON? You are using To loop through the internal object, you use a loop inside the loop:
{"product": {"options": {"42432": {"id": 42432, "title {"Id": 152744, "title" ":" Za 17 mei 2014 "," active ": false}," 166656 ": {" id ": 166656," title ":" wo 4 juni 2014 "," active ": wrong}}}}}}}
& lt; script & gt; $ (document) .ready (function () {$ .get ('http: //exampleproduct.html? For Mat = json ', function (data) {if (data.product.options) {$ .each (data.product (' & lt; li & gt; '+ vartitle +'
& lt; Ul & gt; & Lt; Li & gt; May 8, 2014 & lt; / li & gt; & Lt; Li & gt; May 17, 2014 & lt; / li & gt; & Lt; Li & gt; wo June 4, 2014 & lt; / li & gt; & Lt; / Ul & gt;
value inside the loop, but the object parameter
Values are in .
$ Each (data.product.pop, function (index, value) {var vartitle = values.title; $ ('. Info_ {{product.id}} .datacursuscoll _ {{product.id}}'. (' Lt; li & gt; '+ vartitle +' & lt; / li & gt; ';)});
Editing:
$ Each (data .product.options, function (index, value) {$ .each (values.values, function (index2, values2) {var vartitle = values2.title; $ ('. Info_ {{product.id}}. Datacursuscoll _ {{product.id}} '.) Andand ('
Comments
Post a Comment