I am currently working on this code and would appreciate any assistance. I'm trying to retrieve and parse data from my listApp.json file to display a list with one link. As a beginner, I could use some guidance.
<script type = "text/javascript">
// If the .js files are linked correctly, we should see the following output inside the JavaScript Console
console.log("starting...");
// Retrieving the .json file and applying the function
var json;
// Running the function when the document is ready
$(document).ready(function(){
// Using standard jQuery ajax technique to load a .json file
$.ajax({
type: "GET",
url: "include/listApp.json",
dataType: "json",
success: jsonParser
});
});
// Parsing function
function jsonParser(data) {
JSON = data;
$(JSON).find("games").each(function (){
games = $(this);
var name = $(games).find("name").text();
var url = $(games).find("url").text();
var id = $(games).find("id").text();
console.log(name);
$("#myList").append('<li>'+ "<a href ="+url+">"+name+"</a>"+'</li>');
$('#myList').listview('refresh');
$("#pages").append('<div data-role="page" id = "'+ id +'"><img src = '+ url +'> test</div>');
});
}
</script>