没有响应的ajax请求
I am trying to make a simple login with ajax. The problem i have is that i do not get any response from my request. When I try to use
myurl.com/login.php is_ajax=1&username=test&password=test
I get a succes message back.
$(document).ready(function(){
$("#submit").click(function(){
var form_data = {
usernm: $("#username").val(),
passwd: $("#password").val(),
is_ajax: 1
};
$.ajax({
type:"POST",
url: "myurl.php" ,
data: form_data,
succes: function (response)
{
if (response == 'succes'){
window.location="myurl.html";
}
else{
alert("wrong username password combination")
}
}
});
return false;
});
});
my php:
$is_ajax = $_REQUEST['is_ajax'];
if(isset($is_ajax) && $is_ajax)
{
$uName = $_REQUEST ['username'];
$pWord = $_REQUEST ['password'];
if($uName == 'test' && $pWord == 'test'){
echo 'succes';
}
else{
echo 'false';
}
}
?Briella
2014/04/28 13:09- php
- ajax
- jquery
- 点赞
- 收藏
- 回答
3个回复
