我采用这样的形式,做变量检查jQuery的,然后把它传递到AJAX的PHP文件,但我收到此通知未定义指数
注意:未定义指数:your_name在C:\ XAMPP \ htdocs中\在线3 东西process.php是错在这里 注意:未定义指数:your_email在C:\ XAMPP \ htdocs中\ process.php线路7
这是我在这里的jQuery代码
$(".button").click(function(){
$('.error').hide();
var your_email=$("input#your_email").val();
if(your_email ==""){
$("label#youremail_error").show();
$("input#your_email").focus();
return false;
}
var your_name=$("input#your_name").val();
if(your_name==""){
$("label#yourname_error").show();
$("input#your_name").focus();
return false;
}
var friends_email=$("input#friends_email").val();
if(friends_email==""){
$("label#friendsemail_error").show();
$("input#friends_email").focus();
return false;
}
var friends_name=$("input#friends_name").val();
if(friends_email==""){
$("label#friendsname_error").show();
$("input#friends_name").focus();
return false;
}
var dataString = 'your_email=' + your_email + '&friends_email=' + friends_email + '&your_name=' + your_name + '&friends_name=' + friends_name;
//alert(dataString);
$.ajax({
type: "POST",
url:"process.php",
data: dataString,
success: function(ret) {
alert(ret);
//alert("thank you for signing up");
},
这里是我的PHP
<?php
include 'inc/class.phpmailer.php';
if(isset($_POST['your_name'])){
$your_name=$_POST['your_name'];
}
else{
echo "something is wrong with your name having:";
var_dump($_POST['your_name']);
echo "<br/>";
}
if(isset($_POST['your_email'])){
$your_email=$_POST['your_email'];
}
else{
echo "something is wrong with your email having:";
var_dump($_POST['your_email']);
echo "<br/>";
}
if(isset($_POST['friends_name'])){
$friends_name=$_POST['friends_name'];
}
else{
echo "something is wrong with friends name having:";
var_dump($_POST['friends_name']);
echo "<br/>";
}
我不知道为什么我收到此通知 显然我的$ _POST值没有设置。
我以我的智慧结束了这一次。你知道为什么/何时没有设置$ _POST?
'var_dump($ _ POST);'---总是使用'var_dump()'来查看实际变量中的内容。 *知识* - 这是什么程序员不同于算命先生 – zerkms 2012-04-24 07:36:25
谢谢@zerkms值是NULL :-(我很困惑,为什么 – user1154295 2012-04-24 11:53:23