Currently I am getting data from a mysql database using jquery, but I would like to know how to create content for my webpage based on the data that is received. For example, if I return a JSON object like { “options” : 3 }, then I would like to know how to respond accordingly in the HTML to create 4 list item.
for (i = 0; i < 3; i++){
$('ul#optionsList').append('<li><a href="javascript:void(loadRand());">1.</a> </li>');
}
jQuery Mobile ListView
<ul id="optionsList" data-role="listview" data-theme="g">
</ul>
Thank you in advance.
You have many possibilities how to create and modify DOM elements, here is jsFiddle example that populates unordered list
For more information about creating new elements see
And for better architecture of your page you might consider to use libraries such as Backbone.js (with comprehensive beginner tutorial here)