最近有一项比较着急的工作。要用ajax向php文件传参数,
var btnfct1 = 1;
var xmlHttp;
function createxmlHttpRequest() //创建用于单独提交的xmlHttpRequest对象
{ }; //这里省略,创建的代码
function RequestPost()
{
createxmlHttpRequest(); //调用函数创建xmlHttpRequest对象
var url = "bntrt.php";//提交的处理函数是bttrt.php
xmlHttp.open("POST",url,true); //方法为POST
xmlHttp.onreadystatechange = handlestatechange; //提交响应的处理函数
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(btnfct1); //有参数要提交
}
function handlestatechange()
{
if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
document.getElementById("message").innerHTML = xmlHttp.responseText;
} //调用对象显示响应的内容
}
}
if(isset($_POST['btnfct1']))
{
$bnf1=$_POST['btnfct1'];
}
var_dump($bnf1);
?>
这样能取到 ajax传的值么?
本人菜鸟,急求高手们帮助啊!本人感激不尽啊