$ .ajax成功了,但在php中,我无法从ajax获取数据。
注意:未定义的索引:电子邮件在..
注意:未定义的索引:传入..
$(document).ready(function(){
$(document).on('click',"#bolero-user-login",function(){
var email = $("#edit-name").val();
var pass = $("#edit-pass").val();
// alert (email);
$.ajax({
url:"functions/php/login.php",
type:"POST",
data:{ "email":email,"pass":pass},
beforeSend: function () {
},
success:function(){
alert("success");
alert(email);
$("#edit-name").val(" ");
$("#edit-pass").val(" ");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
},
});
return false;
});
});
PHP:
<?php
define ("root",$_SERVER['DOCUMENT_ROOT']);
// echo root;
include root.'/maroon5/includes/dbh.php';
print_r($_REQUEST);
$email = $_POST['email'];
$pwd = $_POST['pass'];
?>
这是来自firefox的图片
答案 0 :(得分:0)
将AJAX成功转变为
success:function(data){
console.log(data);
$("#edit-name").val(" ");
$("#edit-pass").val(" ");
},
和AJAX页面一样
<?php
define ("root",$_SERVER['DOCUMENT_ROOT']);
// echo root;
include root.'/maroon5/includes/dbh.php';
// print_r($_REQUEST);
$returnArr['email'] = $email;
$returnArr['pwd'] = $pwd;
echo json_encode($returnArr);
?>