weixin_33744141 2013-07-14 22:58 采纳率: 0%
浏览 29

完全被Ajax弄糊涂了

Okay, so I think i'm doing this wrong. I just started working with jquery and Ajax and cannot find any real good tutorials. so i'm basically working off Jquery code i've found and trying to get it to work.

Could someone explain to me why this isn't working? (the login.php file is just a login script that returns "true" if it was run successfully and "false" if it fails).

<?php
include('./includes/config.php');
echo $_SESSION['uid'];
?>
<a href='logout.php'>logout</a>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<form method="post" id='login_form'>
<input type='text' name='username' id='username'> 
<input type='password' name='password' id='password'>
<input type='submit' id='submit'>
</form>
<script type='text/javascript'>
$('#login_form').submit(
function()
{
    $.ajax({
        type:POST, 
        url:'login.php', 
        success: function(){alert('win!')}
    })
})
</script>
  • 写回答

1条回答 默认 最新

  • weixin_33690367 2013-07-14 23:07
    关注

    In your code, it should be type:'POST' or type:"POST", not type:POST.

    The official explanation page is actually quite good: http://api.jquery.com/jQuery.ajax/ Just grab some of the sample code from there.

    评论

报告相同问题?