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.

    评论

报告相同问题?

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图