xhr post request js
javascript xhr post request
Example for javascript xhr request with get method
Example for javascript xhr request with get method
In this http request js example we sending get request to test.php,
if request retrive status code 200 you can see in console “working”,
if not “not working”
Example code
/////////////////////////////////////////////////////////////////////////////////////////////////
// variable remote php file
varurl = ‘post.php’;
// creating new xhr
varnewxhr = newXMLHttpRequest();
newxhr.onreadystatechange = function() {
// validation if code status 200
if (newxhr.status == 200) {
console.log(‘working’);
}
else{
console.log(‘not working’);
}
};
newxhr.open(“POST”, url, true);
newxhr.send();
/////////////////////////////////////////////////////////////////////////////////////////////////
