zoukankan      html  css  js  c++  java
  • jquery .ajax

    view:

        $(document).ready(function() {
            var ss="asdff";
            $(".check").click(function(){
                alert("OK");    
                $.ajax({
                type:'get',
                url:'<?php echo URL::base(true)?>purchasepay/finance/purchasepay/payaction',
                async:false,
                data:{pro:ss,needpay:ss},
                success:function(data)
                {
                    alert(data);
                },
                error:function(){
                    alert("error");
                }
            });
                });
        });
    
        

    controller:

            $s=$_GET["pro"];
            
            echo json_encode ( $s );      

    $.each()

      $.each(data, function(commentIndex, comment){
                                   html += '<div class="comment"><h6>' + comment['username']
                                             + ':</h6><p class="para"' + comment['content']
                                             + '</p></div>';
                             });

    $.each()函数不同于JQuery对象的each()方法,它是一个全局函数,不操作JQuery对象,而是以一个数组或者对象作为第1个参数,以一个回调函数作为第2个参数。回调函数拥有两个参数:第1个为对象的成员或数组的索引,第2个为对应变量或内容。

  • 相关阅读:
    7.Mongodb安全性流程
    6.Mongodb索引
    5.Mongodb聚合
    8-进程管理
    7-安装包管理
    6-文件系统
    5-权限用户组
    27-ATM+购物车程序
    26.本章小结
    名词解释
  • 原文地址:https://www.cnblogs.com/canbefree/p/3709846.html
Copyright © 2011-2022 走看看