ajax post this page
function postData(url) { return new Promise((resolve, reject) => { var xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.onload = function() { var data = xhr.responseText; resolve(data); }; xhr.onerror = function() { reject(Error(xhr.statusText)); }; xhr.send(); }); } postData("/data.json") .then(data => { console.log(data); }) .catch(error => { console.error(error); });