wordpress中的Php-Ajax
我正在使用wordpress主题创建一个网站。在我的联系人表单中,我使用ajax将多个值传递给另一个php文件wordpress中的Php-Ajax,php,wordpress,Php,Wordpress,我正在使用wordpress主题创建一个网站。在我的联系人表单中,我使用ajax将多个值传递给另一个php文件 <script language="javascript"> function addAnnouncement1() { var name = document.getElementById("name").value; var email_id = document.getElementById("email_id").valu
<script language="javascript">
function addAnnouncement1()
{ var name = document.getElementById("name").value;
var email_id = document.getElementById("email_id").value;
var mb_no = document.getElementById("mb_no").value;
alert("ok");
var xmlhttp; if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} xmlhttp.onreadystatechange=function()
{ if (xmlhttp.readyState==4)
{ if(xmlhttp.status==200){ document.getElementById("result").innerHTML=xmlhttp.responseText;
}
} }
var variables = "email_id="+email_id+"&name="+name+"&mb_no="+mb_no; xmlhttp.open("POST", "../contact_us.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(variables);
return false;
}
</script>
在传递contact_us.php文件时,我只能单独获得email_id值。错误在于它不接受“&”符号。请澄清我的疑问,如何传递该值?在代码中,变量行是var variables=email_id=+email_id+&;名称=+名称+&;mb_no=+mb_no;但是当你写了bug在这行的时候,它就没有amp;。您使用哪一行?我使用了这两种格式nothing is working尝试使用alert显示变量的值,看看您得到了什么。请勿使用&;,只要使用&。
var variables = "email_id="+email_id+"&name="+name+"&mb_no="+mb_no;