$.post javascrip code example
Example 1: post method javascript code
const postData = async ( url = '', data = {})=>{
console.log(data);
const response = await fetch(url, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
try {
const newData = await response.json();
console.log(newData);
return newData;
}catch(error) {
console.log("error", error);
}
}
Example 2: $.post javascript
$.post(
"path/to/your/php/file",
{
param1: "Value",
param2: "Value"
},
function(data) {
}
);