我不知道问题出在哪里。我尝试将电子邮件和密码传递给php页面,但它总是"未定义索引电子邮件.."'&#39 ;索引页面没问题,但是php页面无法从ajax接收任何数据,我从未见过这样的情况。 索引页:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click',"#bolero-user-login",function(){
var email = $("#edit-name").val();
var pass = $("#edit-pass").val();
$.ajax({
url:"login.php",
type:"POST",
data:{ "email":email,"pass":pass},
success:function(data){
console.log(data);
alert(data);
$("#edit-name").val(" ");
$("#edit-pass").val(" ");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
},
});
return false;
});
});
</script>
</head>
<body>
<form id="userid" class="user-login-id" >
<div style="height: 204px;">
<div class="form-name form-it">
<label for="edit-name" >E-mail Address
<span >*</span> <br/></label>
<input id="edit-name" type="text" name="email" />
</div>
<div class="form-pass form-it" id="it">
<label for="edit-pass">Password<span >*</span><br/> </label>
<input id="edit-pass" type="text" name="pass" />
</div>
<div class="form-ac">
<input id="bolero-user-login" type="submit" value="Login" >
</div>
</div>
</form>
</body>
</html>
PHP页面:
<?php
//
//
define ("root",$_SERVER['DOCUMENT_ROOT']);
// echo root;
include root.'/maroon5/includes/dbh.php';
var_dump($_REQUEST);
$email = $_POST['email'];
$pwd = $_POST['pass'];
//echo "$email";
?>