• 夺命雷公狗jquery---57Ajax+XML实现对大批量数据的编辑


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title></title>
            <script src="js/jquery.js"></script>
            <script>
                $(function(){
                    $('#btnok').bind('click',function(){
                        var first = $('#first').val();
                        var second = $('#second').val();
                        var data = {
                            'first':first,
                            'second':second
                        };
                        //发送ajax请求
                        $.post('ajax6.php',data,function(msg){
                            //第一种方案
                            /*
                            var jia = msg.getElementsByTagName('jia')[0].childNodes[0].nodeValue;
                            var jian = msg.getElementsByTagName('jian')[0].childNodes[0].nodeValue;
                            var cheng = msg.getElementsByTagName('cheng')[0].childNodes[0].nodeValue;
                            var chu = msg.getElementsByTagName('chu')[0].childNodes[0].nodeValue;
    
                            alert(jia+'--'+jian+'--'+cheng+'--'+chu);
                            */
    
                            //第二种方案
                            var jia = $(msg).find('jia').text();
                            var jian = $(msg).find('jian').text();
                            var cheng = $(msg).find('cheng').text();
                            var chu = $(msg).find('chu').text();
                            
                            alert(jia+'--'+jian+'--'+cheng+'--'+chu);
                        },'xml')
                    });
                });
            </script>
        </head>
        <body>
            第一个数:<input type="text" id="first" />
            <hr />
            第二个数:<input type="text" id="second" />
            <hr />
            <input type="button" id="btnok" value="计算" />
        </body>
    </html>

    PHP代码如下:

    <?php
        $first = $_POST['first'];
        $second = $_POST['second'];
    
        $jia = $first + $second;
        $jian = $first - $second;
        $cheng = $first * $second;
        $chu = $first / $second;
    
        $str = <<<str
            <counter>
                <jia>$jia</jia>
                <jian>$jian</jian>
                <cheng>$cheng</cheng>
                <chu>$chu</chu>
            </counter>
    str;
        header("Content-Type:text/html;charset=utf-8");
        echo $str;
  • 相关阅读:
    NumPy笔记:运算符(exp,sqrt,square)
    NumPy笔记:常用操作
    php字符操作
    laravel如何实现批量插入
    php中@符号的作用
    laravel如何实现数据的批量插入
    如何在laravel框架中使用阿里云的oss
    laravle如何设置mysql数据表前缀
    thinkphp视图中如何调用并且向控制器传参数
    thinkphp如何隐藏入口文件index.php
  • 原文地址:https://www.cnblogs.com/leigood/p/4924327.html
Copyright © 2020-2023  润新知