javascript - Trying to populate using JSON, it is not working -


I want to populate a UL with a set of options using JSON.

JSON:

  {"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}}}}}}}   

My HTML code:

  
ul class

My script: Pre> & 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 +'

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:

  & 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;   

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 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:

To loop through the internal object, you use a loop inside the loop:

  $ 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

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -