I am just using Jquery
to create a list of my products in my html document from the json
data. I was just trying to be able to sort my products through clicking my heading name which will sort my products by alphabetical order.
I have researched on how to do this but cant find/understand how i can do this through using my data from json
.
Any help is appreciated. Thanks
function drawPage() {
$.get('/products', function (data) {
console.log(data);
var prod = data.products;
for(var i=0; i<prod.length; i++){
var el = document.createElement('P');
el.innerHTML = prod[i].name;
$('#app').append(el);
}
})
}
document.addEventListener('load', drawPage());