Yngvarr

Generation

generate functionSat, 04 Feb 2023

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); });

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant