weixin_33749131 2012-07-07 18:55 采纳率: 0%
浏览 88

如何通过单击按钮捕获表单的数据?

我想通过单击按钮捕获表单的数据,并使用ajax、json将其发送到php页面。 现在,当我注释了AJAX部分时,单击按钮便会发出警报“ hello hello”。 当我通过取消包括ajax部分的注释时,不仅没有得到任何错误,而且“ hello hello”警报也没有出现。 我觉得这很奇怪——为什么会这样呢?

这是我的ajax:

<script>
    $(document).ready(function () {
        $("#btn").click( function() {
        alert('hello hello');
        /* Coomenting starts here
        $.ajax({
            url: "connection.php",
            type: "POST",
            data: {
                id: $('#id').val(),
                name: $('#name').val(),
                Address: $('#Address').val()
            }
            datatype: "json",
            success: function (status)
            {
                if (status.success == false)
                {
                    alert("Failure!");
                }
                else 
                {
                    alert("Success!");
                }
            }
        });
        */
    //commenting ends here.
    //basically i just commented out the ajax portion 
    });
    });
</script> 
  • 写回答

3条回答 默认 最新

  • weixin_33725272 2012-07-07 18:58
    关注

    Check comma syntax after data parameter:

    data: {
             id: $('#id').val(),
             name: $('#name').val(),
              Address: $('#Address').val()
          },
    
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?