Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Changes
Page history
Update JQuery
authored
Apr 26, 2022
by
Joel H
Show whitespace changes
Inline
Side-by-side
Web/Javascript/JQuery.md
View page @
a2a81d5f
...
...
@@ -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