Skip to content
Update JQuery authored by Joel H's avatar Joel H
......@@ -130,3 +130,20 @@ $.ajax('data/item.json', {
})
```
```javascript
//ajax POST
let id = $(this).parent().data('id'); //from data-id attribute
$.ajax('data/addToCart.json', {
type: 'post',
data: { id: id}, //these are the things that we send to the server
dataType: 'json',
contentType: 'application/json'
})
.done(function(response){
if(response.message === 'success'){
let price = response.price;
console.log(price);
}
});
```
\ No newline at end of file