아약스 양식 제출과 관련된 문제가 있습니다. 동적으로 양식을 제출하고 처리하기 위해 서버 측에서 PHP를 사용하고 있습니다. 이것은 아작스 성공 함수입니다. 사용자가 유효한 경우아약스 양식 요청
$.ajax({
type: "POST",
url: "register.php",
data: "uname="+uname+"&eid="+eid+"&pwd="+pass+"&cpwd="+cpass+"&country="+coun+"&contact="+contact,
dataType: "html",
success: function(data){
if(data!="error")
{
//alert(data);
$("#user_status", window.parent.document).html("Welcome "+data+" | <a href='forum/logout.php'>Logout</a>");
if(window.parent.document.getElementById('post_user_name'))
$("#post_user_name", window.parent.document).html(msg);
parent.$.fancybox.close();
}
if(data=="error")
{
//alert(data);
$("#status").html("<span><center><font class='formright err_msg' style='width:176px;'>The user is already register with us.</font><center></span>");
return false;
}
지금 그는에 기록되고 국지적 유효한 부분이 잘 작동 "이미 존재합니다"와 같은 f를하지 오류가있을 가지고 있지만 무효을 위해 나는 PHP 파일에서 오류를 반환 하지만 여전히 내 오류 메시지가 표시되지 않습니다 그냥 오류가 내 양식 (JQuery와 fancybox) PHP 코드 fancybox를 사용하고있는 screen.I에 인쇄되어
if($_POST['pwd']==$_POST['cpwd'])
{
$username = $_POST['uname'];
$email = $_POST['eid'];
$password = md5($_POST['pwd']);
$cpassword = $_POST['cpwd'];
$contact_no = $_POST['contact'];
$country = $_POST['country'];
$cnt = $checkUser['cnt'];
if($cnt!=0)
{
echo "error";
//exit;
/*$_SESSION['error_msg'] = 'Email Address already exists';
redirect_to_link("index.html");*/
}
else
{
//echo "entered here";
$userArray = array();
//$user = return_post_value($_POST['uname']);
$userArray['uname'] = return_post_value($_POST['uname']);
$userArray['email'] = return_post_value($_POST['eid']);
$userArray['password'] = md5(return_post_value($_POST['pwd']));
$userArray['contact_no'] = return_post_value($_POST['contact']);
$userArray['country'] = return_post_value($_POST['country']);
//print_r($userArray);
//exit;
$userObj->addUserValue($userArray);
$_SESSION['username']= $userArray['uname'];
echo $userArray['uname'];
// return $user;
}
에코 $ userArray [ 'UNAME'입니다 ]; 부분은 작동하지만 에코 "오류"가 아닙니다. 방화 광 응답 헤더에 체크되어 반환 된 오류 단어를 볼 수 있습니다. 누구든지 그것에 불을 붙일 수 있습니까?
감사
당신은 자바 스크립트에서 데이터에 대한 경고를 할 수 있습니다. 그리고 왜 당신은 거짓을 반환하고 있습니까? if (data == 'error') 조건? –
그래, 그걸 시도했지만 거기에 도달하지 못한다. 여전히 (데이터! = "오류") 루프에 들어간다! : P 나는 ** http://www.proptiger.com/ 헤더 ** 등록 ** 링크 (양식)와 비슷한 것을하려고합니다. 감사합니다. – KillABug
성공 함수의 데이터 값을 출력하고 여기에 출력을 제공 할 수 있습니까? –