我的 PHP/AJAX/jQuery 登录脚本有什么问题?
我有这个代码:
dologin.php 文件是:
<?php
$is_ajax = $_REQUEST['is_ajax'];
if(isset($is_ajax) && $is_ajax) {
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
if($username == 'demo' && $password == 'demo') {
echo "success";
}
}
?>
index.php 文件是:
<html>
<head>
<script type= "text/javascript" scr= "jquery.latest.min.js" ></script>
<script type="text/javascript">
$(documnt).ready(function) {
$('#login').click(function) {
var action = $("#form1").attr("action");
var form_data = {
username: $("#username").val(),
password: $("#password").val(),
is_ajax: 1
};
$.ajax({
type: 'POST',
url: action,
data: form_data,
success: function(response)
{
if(response == 'success')
{
$("form1").slideUp('slow', function() {
$("#message").html('<p class="success"> You have logged in. </p>');
});
}
else
$("#message").html('<p class="error"> Invalid username and/or password. </p>');
}
});
return false;
});
});
</script>
</head>
<body>
<p> </p>
<div id="content">
<h1>Login form</h1>
<form name="form1" id="form1" method="post" action="dologin.php">
<p>
<label for="username"> Username:</label>
<input type="text" id="username" name="usernmae" />
</p>
<p>
<label for="password">Password:</label>
<input type="text" id="password" name="password" />
</p>
<p>
<input type="submit" id="login" name="login" value="Login" />
</p>
</form>
</div>
</body>
</html>
它不断给我这个错误信息:
Notice: Undefined index: is_ajax in C:\wamp\www\final project\passnumber\dologin.php on line 3
我是 AJAX 和 jQuery 的新手,请你帮帮我?