Home  >  Article  >  Backend Development  >  url-一个php文件向另一个php文件传变量,$_POST取不到值

url-一个php文件向另一个php文件传变量,$_POST取不到值

WBOY
WBOYOriginal
2016-06-02 11:30:511131browse

phpurlxmlhttprequest

index.php里:
var request = new XMLHttpRequest();
request.open("POST","test.php");
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var str="name="+url;
request.send(str);

text.php里:
$url=$_POST['name'];
echo $url;
两个文件在同一工程下,url是个变量,text.php执行会提示undefined index:name
readyState=4 Status=0 ,请问哪儿出错了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn