$.post javascript
const postData = async ( url = '', data = {})=>{
console.log(data);
const response = await fetch(url, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
},
// Body data type must match "Content-Type" header
body: JSON.stringify(data),
});
try {
const newData = await response.json();
console.log(newData);
return newData;
}catch(error) {
console.log("error", error);
}
}
//$.post with jQuery
$.post(
"path/to/your/php/file",
{
param1: "Value",
param2: "Value"
},
function(data) {
//Callback here
}
);
Also in JavaScript:
- password validation with regular expression in javascript
- how to use fetch() to fetch an image from database in js
- graphql yoga access http headers
- puppeteer js onblur
- shorthand if in javascript with return
- math js
- random number generator js
- jest axios manual mock
- declare array in javascript
- javascript eval passing variable
- javascript appendchild at index
- ejs include dynamic partial
- install node modules
- js modulo not working
- angular get response headers
- javascript remove duplicate strings from array
- trigger click jquery
- datepicker in react
- how to get width of inline elements js
- react materialize cdn
- how to add multiple comment in react
- date difference
- date.parse string to javascript
- react chunk file too large