I'm trying to send back a string equation, for example "3+3", but when PHP receives it, it appears as "3 3" instead. Somewhere along the line, the operators are getting erased.
function sendEquation() {
let str = document.querySelector(".equation").innerText;
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
document.querySelector(".equation").innerHTML = this.responseText;
}
};
xhr.open("GET", "Scripts/Maths.php?q=" + str, true);
xhr.send();
}
I think it might be getting lost in this code. If my assumption is right, how do I stop javascript from interpreting the value I want it to store and just send me the string as it's written?
+or it'll be converted to an space:xhr.open("GET", "Scripts/Maths.php?q=" + encodeURIComponent(str), true);