?Briella 2014-04-28 13:09 采纳率: 0%
浏览 36

没有响应的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';
}
}   
  • 写回答

3条回答 默认 最新

  • weixin_33709609 2014-04-28 13:12
    关注

    you should use

    $uName = $_REQUEST ['usernm'];
    $pWord = $_REQUEST ['passwd'];
    

    INSTEAD of

    $uName = $_REQUEST ['username'];
    $pWord = $_REQUEST ['password'];
    

    in your php file and change succes to success

    评论

报告相同问题?