为什么我不能在Mozilla的Net选项卡中看到php调用?
这就是我将数据发送到php页面的方式为什么我不能在Mozilla的Net选项卡中看到php调用?,php,jquery,ajax,firefox,Php,Jquery,Ajax,Firefox,这就是我将数据发送到php页面的方式 $('#registerForm').submit( function() { event.preventDefault(); callAjaxSubmitMethod(this); } ); function callAjaxSubmitMethod(form) { $.ajax({ type: "POST"
$('#registerForm').submit(
function()
{
event.preventDefault();
callAjaxSubmitMethod(this);
}
);
function callAjaxSubmitMethod(form)
{
$.ajax({
type: "POST",
url: "lib/registration_validate.php",
data: $("#registerForm").serialize(),
dataType: 'json',
success: function(response)
{
console.log("cominggggg");
alert("s"+response.status);
},
error:function(response)
{
alert("e"+response.status);
},
complete:function(response)
{
console.log("Completed.");
}
});
}
我正在处理重复的电子邮件注册。如果我在chrome中运行此代码,我可以在net选项卡中看到php。我可以看到控制台已完成,e200处于警报状态
在我的mozilla浏览器中,我没有收到任何控制台字符串、警报。我在Net选项卡中也没有得到php页面调用
我也刚刚清除了缓存。所以它也不是来自缓存。由于mozilla内存不足,我清除了localStorage
我甚至不理解这种行为。不知道如何进一步调试。我对你的代码做了一些修改,chrome似乎接受了你的方式,firefox没有 因此,与此相反:
<?php
include 'configdb.php';
session_start();
global $connection;
echo "oops";
if(isset($_POST['submit']) && $_POST['email']!='' && $_POST['password']!='')
{
$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)
{
$response['status']='Email Already Exists';
echo json_encode($response);
exit;
}
}?>
这样做:
$('#registerForm').submit(
function()
{
event.preventDefault();
callAjaxSubmitMethod(this);
}
);
请注意,我还添加了事件参数,但您缺少该参数。我认为您最好在FireFox中使用Firebug,如果您在chrome中没有收到警报,那么您的语法可能不正确?这里是firebug的链接:我只使用firebug。你的代码已经运行了吗?
$('#registerForm').on('submit', function(event) {
event.preventDefault();
callAjaxSubmitMethod(this);
}
);