javascript - How to print dynamic contents of array at different positions in HTML5 -
I have to get data from the PHP web service in an array and then it must be displayed on the HTML page using Javascript. I have used a for
loop to do this but it does not provide proper output. Output is replaced with innerHTML
. Please help with your suggestions here is my code:
function jsondata (data) {warning ("JasonData") ; Var parsedata = JSON.parse (JSON.stringify (data)); Var main_category = parsedata ["main category"]; {Menu = JSON.stringify (main illustration [i]) for (var i = 0; i & lt; = main_category.length; i ++); Menu_id [i] = Menu ['MacTit']; Menu_title [i] = Menu ['MacTuttle']; Menu_img [i] = Menu ['Mactize']; Pop_array.push (menu_id [i], menu_title [i], menu_image [i]); // warning (pop_array); (Var i = 0; i & lt; main_category.length; i ++) {Warning ("for start"); Var range = document.createElement ("li"); Document.getElementById ("MyList") appendChild (Category). //document.getElementById("mylist").innerHTML='<table><tr><td>'+pop_array[i]+'</td></tr></table>, ' ; Document.write (pop_array.join ("& lt; br & gt; ")); Warning ("for the end"); }}}}
however why do not I get pop_array
Used here but I think that you are trying to display the category
information as li
tag.
You should set the category. Internal HTML
instead of document.getElementById ("mylist"). InnerHTML
.
function jsondata (data) {var parsedata = JSON.parse (JSON. Stringify (data)); Var main_category = parsedata ["main category"]; (Var i = 0; i & lt; main_category.length; i ++) for {var menu = main square [i]; Var range = document.createElement ("li"); Category.innerHTML = Menu ['MacTuttle']; // Create your own HTML document.getElementById ("mylist"). AppendChild (category); }}
Comments
Post a Comment