Ajax调用不传递php变量

Ajax调用不传递php变量,php,ajax,Php,Ajax,我在页面上有php变量$subscriber\u phone和$agent\u phone,在单击ID为call的按钮后,我对call.php页面进行ajax调用。我有以下ajax代码 customernumber的警报给出了未定义的警告。php变量未被传递 阿贾克斯: 我做错什么了吗???请求帮助 问题在 customernumber: "<?php echo $subscriber_phone;?>"; 这是非对象上下文中的对象语法。用等号代替 $(&quo

我在页面上有php变量$subscriber\u phone和$agent\u phone,在单击ID为call的按钮后,我对call.php页面进行ajax调用。我有以下ajax代码

customernumber的警报给出了未定义的警告。php变量未被传递

阿贾克斯:

我做错什么了吗???请求帮助

问题在

customernumber: "<?php echo $subscriber_phone;?>";
这是非对象上下文中的对象语法。用等号代替

$("#call").click(function(){
customernumber = "<?php echo $subscriber_phone;?>";
agentnumber = "<?php echo $agent_phone;?>";
alert(customernumber);

在浏览器中查看源代码,您将能够看到页面是如何被解析的,因为PHP会在页面发送到浏览器之前进行处理。如果数据没有显示在那里,那么您需要调查为什么它没有显示。php在页面中正确显示了电话号码。我回显了。提示显示未定义您没有将值赋给customernumber correct。我很惊讶它没有给出其他错误,因为您正在非对象上下文中使用对象语法。你需要用=来赋值。@aynber我的天哪…想知道我在做什么。非常感谢。是的,我更正了。不知道我在做什么。我做了一些改变,但在这个过程中错过了。非常感谢你。
$("#call").click(function(){
customernumber = "<?php echo $subscriber_phone;?>";
agentnumber = "<?php echo $agent_phone;?>";
alert(customernumber);