zoukankan      html  css  js  c++  java
  • 黄聪:Jquery+php+ajax实现表单异步提交,动态添加回复评论

    HTML代码:

    ---------------------------------------------------------------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> TEST </title>
    <meta name="generator" content="editplus" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
    <script type="text/javascript">
    <!--
    $(document).ready( function () {
    $('#btn').click ( function () {
        $.ajax({
        url: 'http://localhost/1.php',
        type: 'POST',
        data:'name='+$('#name').val(),
        dataType: 'html',
        timeout: 1000,
        error: function(){
         alert('Error loading XML document');
        },
        success: function(html){
         $('#text').html(html);
        }
        });
    });
    })
    //-->
    </script>
    </head>

    <body>
    <div id="text"></div>
    <input type="text" id="name" name="name" />
    <input type="button" value="DO IT ." id="btn"/>
    </body>
    </html>

    ---------------------------------------------------------------------------

    1.PHP代码

    ---------------------------------------------------------------------------

    <?php
    $name = $_POST['name'];
    echo "you say : ".$name;

    ?>

    ---------------------------------------------------------------------------

    

  • 相关阅读:
    网络协议
    窗口TOPMOST属性设置失败
    自绘之----对话框
    图书推荐
    MFC自绘之WM_ERASEBKGND
    批处理获取当前路径
    checkBox 自绘
    第四章:基于TCP套接字编程(三)
    第四章:基于TCP套接字编程(二)
    第四章:基于TCP套接字编程(一)
  • 原文地址:https://www.cnblogs.com/huangcong/p/2009638.html
Copyright © 2011-2022 走看看