Skip to content
Update JQuery authored by Joel H's avatar Joel H
......@@ -109,4 +109,24 @@ $.ajax('data/item.json')
})
//Can add a 2nd parameter to ajax to indicate information :
$.ajax('data/item.json', {
dataType: 'json',
contentType: 'application/json',
cache: false
})
.done(function(response){
console.log(response.items);
let items = response.items;
items.forEach(function(item){
addItem(item.name, item.description, item.price, item.moreInfo);
})
})
.fail(function(request, errorType, errorMessage){
console.log(errorMessage);
})
.always(function(){
console.log("always called");
})
```
\ No newline at end of file