post data javascript code example
Example 1: javascript send post
var xhr = new XMLHttpRequest();
xhr.open("POST", yourUrl, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
value: value
}));
Example 2: $.post javascript
$.post(
"path/to/your/php/file",
{
param1: "Value",
param2: "Value"
},
function(data) {
}
);
Example 3: js make post request
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (this.readyState != 4) return;
if (this.status == 200) {
var data = JSON.parse(this.responseText);
}
};
xhr.open('GET', yourUrl, true);
xhr.send();