javascript - loop json object and add values to existing UL elements -


How can I add the value of the JSON object to an existing unordered list (in the correct sequence) on a span tag?

Tried this but it is only adding the last value of the object to the span tag:

  $ Each (case_data ['stage' + AD + '], function (key, value) {$ (' # phase info le '). Each (function () {$ (this) .find (' span '). (Values);});}); "Duration": "1 year", "Age": "   45", "Hb1c": "7.9", "FMG": "7.9", "BMI "": "2 years", "age": "46", "weight loss", "weight loss", "base line": "metformin"}, "step1": " "HbA1c": "8.1", "FPG": "8.3", "BMI": "29", "complications": "limited progress hypertension", "baseline": "metapharmin"}, "Step 2": "5 years", "Age": "49", "HBA1c": "8.2", "FPG": "8.4", "BMI" "" ":" " "", "Complications": "Patient takes quick retirement, daily physical c "Duration": "10 Years", "Age": "55", "Hb1c": "9.3", "Step 3": "Base Line": "Base Line": "Metformin"}, "Step 3" "FPG": "9.8", "BMI": "33", "Complications": "Diagnosis of Retinopathy Grade 2", "Baseline": "Metformin"}}  

HTML

  & lt; ul id = "stageInfo" class = "stage_info" & gt; 
  • 1 & lt; duration & gt;
  • 2 & lt; / l & gt; & lt; / li & gt; & Lt; Li & gt; 3 & lt; Period & gt; & Lt; / Span & gt; & Lt; / Li & gt; & Lt; Li & gt; 4 & lt; Period & gt; & Lt; / Span & gt; & Lt; / Li & gt; & Lt; Li & gt; 5 & ​​lt; Period & gt; & Lt; / Span & gt; & Lt; / Li & gt; & Lt; Li & gt; 6 & lt; Period & gt; & Lt; / Span & gt; & Lt; / Li & gt; & Lt; Li & gt; 7 & lt; Period & gt; & Lt; / Span & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
  • similarly:

      var ind = 0 ; $ .each (case_data ['stage' + id], function (key, value) {$ ('# stageInfo li'). Eq (IND ++). ('Span'). Text (value);});  

    Comments