我採用這樣的形式,做變量檢查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