问题
I've got the following XMLHttpRequest:
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "includes/stats.inc.php", true);
xhttp.send("date=" + date);
I want to pass the date variable through to the php file which does some stuff.
I have double checked and the php file does some stuff [without the date variable] if I 'call' it using a form:
<form action="includes/stats.inc.php" method="post">
<button type="submit" name="login-submit">test</button>
</form>
But it's my understanding I need to use an XMLHttpRequest to pass the variable. I've searched and tried various ways of doing it and it doesn't seem to work. When doing:
xhttp.responseText
it just returns the HTML code. Any ideas? Thank you
来源:https://stackoverflow.com/questions/62150613/xmlhttprequest-passing-parameter-to-php-file