下面的post是什么意思?
ajaxRequest = new XMLHttpRequest();
ajaxRequest.open("POST", "url" + queryString, true);
因为我无法使用 url 中的 $_POST['var']
访问变量,但是
使用 $_REQUEST['var']
我可以访问值..
最佳答案
当您从 $_POST
读取数据时,您应该在 HTTP 正文中传递参数,而不是使用查询字符串。
您需要发送您的参数,如下例所示:
ajaxRequest = new XMLHttpRequest();
ajaxRequest.open("POST", "your_service.php", true);
ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajaxRequest.send("var=100&another_var=200");
关于php - XMLHttpRequest 中的 POST 或 GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2243656/