Gmz1023
Gmz1023

Reputation: 119

Utterly confused by 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>

Upvotes: -1

Views: 59

Answers (1)

Assaf Hershko
Assaf Hershko

Reputation: 1934

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.

Upvotes: 1

Related Questions