im still a beginner in this field i wanted to send the information from the value that I created from javascript to the other file external php or i mean from client-side to server-side as an example i have loop and value stored in 'i' and i wanna send it to php how? i googled and see some ppl say's use ajax method i still don't know it anyway i tried as an experiment like this it actually worked it only prints a value for me in console but idk how to send it to php
var myrequest = new XMLHttpRequest();
myrequest.open('POST','upload.php',true);
xhr.setRequestHeader('Content-Type',"application/x-www-form-urlencoded");
myrequest.onreadystatechange = function() {
myrequest.onload = function() {
console.log(this.responseText);
}
let data = JSON.stringify({'test': 'test'});
myrequest.send(data);
}
in php file i tried as an example to call variable from js $_post['test'] i dunno how but it didn't work