为什么我没有从 php 得到任何东西?
Why am i not getting anything from php?
$('#registerForm').submit(
function()
{
callAjaxSubmitMethod(this);
//event.preventDefault();
}
);
是我里面的函数dom准备好了。
function callAjaxSubmitMethod(form)
{
$.ajax({
type: "POST",
url: "lib/registration_validate.php",
data: $("#registerForm").serialize(),
success: function(response)
{
alert("s"+response.status);
},
error:function(response)
{
alert("e"+response);
}
});
}
是实际的函数定义。
我的php内容是
<?php
include 'configdb.php';
session_start();
global $connection;
echo "oops";
if(isset($_POST['submit']) && $_POST['email']!='' && $_POST['password']!='')
{ //use empty....
$email= $_POST['email'];
$sql1 = "SELECT * FROM Users WHERE emailID = '$email'";
$result1 = mysqli_query($connection,$sql1) or die("Oops");
if (mysqli_num_rows($result1) > 0)
{
$_SESSION['email_exist']="Email Already Exists";
//die({'status':'Email Already Exists'});
//echo var_dump($_SESSION);
//echo '{status:0}' ;
//exit;
}
}
?>
我没有收到任何提醒。如果我启用 event.preventDefault()
我在 mozilla 中得到 out of memory error
并且在 chrome 中得到 sundefined
警报。
使用
if(isset($_POST['submit']) && $_POST['email']!='' && $_POST['password']!='')
{ //use empty....
$email= $_POST['email'];
$sql1 = "SELECT * FROM Users WHERE emailID = '$email'";
$result1 = mysqli_query($connection,$sql1) or die("Oops");
$response = array();
if (mysqli_num_rows($result1) > 0)
{
$_SESSION['email_exist']="Email Already Exists";
$response['status']='Email Already Exists';
}
else{
$response['status']='Allis OK';
}
echo json_encode($response); die;
}
并在 ajax 中添加:
dataType:'json'
编辑
关于如何设置数据类型的信息:
$.ajax({
type: "POST",
dataType:'json',
url: "lib/registration_validate.php",
data: $("#registerForm").serialize(),
success: function(response)
{
alert("s"+response.status);
},
error:function(response)
{
alert("e"+response);
}
});
$('#registerForm').submit(
function()
{
callAjaxSubmitMethod(this);
//event.preventDefault();
}
);
是我里面的函数dom准备好了。
function callAjaxSubmitMethod(form)
{
$.ajax({
type: "POST",
url: "lib/registration_validate.php",
data: $("#registerForm").serialize(),
success: function(response)
{
alert("s"+response.status);
},
error:function(response)
{
alert("e"+response);
}
});
}
是实际的函数定义。
我的php内容是
<?php
include 'configdb.php';
session_start();
global $connection;
echo "oops";
if(isset($_POST['submit']) && $_POST['email']!='' && $_POST['password']!='')
{ //use empty....
$email= $_POST['email'];
$sql1 = "SELECT * FROM Users WHERE emailID = '$email'";
$result1 = mysqli_query($connection,$sql1) or die("Oops");
if (mysqli_num_rows($result1) > 0)
{
$_SESSION['email_exist']="Email Already Exists";
//die({'status':'Email Already Exists'});
//echo var_dump($_SESSION);
//echo '{status:0}' ;
//exit;
}
}
?>
我没有收到任何提醒。如果我启用 event.preventDefault()
我在 mozilla 中得到 out of memory error
并且在 chrome 中得到 sundefined
警报。
使用
if(isset($_POST['submit']) && $_POST['email']!='' && $_POST['password']!='')
{ //use empty....
$email= $_POST['email'];
$sql1 = "SELECT * FROM Users WHERE emailID = '$email'";
$result1 = mysqli_query($connection,$sql1) or die("Oops");
$response = array();
if (mysqli_num_rows($result1) > 0)
{
$_SESSION['email_exist']="Email Already Exists";
$response['status']='Email Already Exists';
}
else{
$response['status']='Allis OK';
}
echo json_encode($response); die;
}
并在 ajax 中添加:
dataType:'json'
编辑
关于如何设置数据类型的信息:
$.ajax({
type: "POST",
dataType:'json',
url: "lib/registration_validate.php",
data: $("#registerForm").serialize(),
success: function(response)
{
alert("s"+response.status);
},
error:function(response)
{
alert("e"+response);
}
});