• ajax局部更新


    js
    
    //点击启用
            $(".status").on("click",function(){
                var id = $(this).attr("statusId");
                var customName = $(this).attr("customName");
                var customStatus = $(this).attr("value");
                var statusId = $(this).attr("statusId");
                if(customStatus == 1){
                    strcustomStatus = "停用";
                }else{
                    strcustomStatus = "启用";
                }
                alert(customStatus);
                //alert(customName);
                //alert(id);
                ymPrompt.win({ 
                                260,
                                   height:150,
                                icoCls: '',
                                message:'<div style="padding-top:25px;" class="message" align="center">您确定要'+strcustomStatus+'【'+customName+'】这个客户吗?</div>',
                                titleBar:false,
                                winPos:'c',
                                   btn:[['OK','ok'],['Cancel','no']],
                                   handler:function getButton(btn){
                                       if(btn == "ok"){
                                           $.ajax({
                                               type:"Post",
                                               data:{"customStatus":customStatus,"id":id},
                                               dataType:"json",
                                               url:classpath+"/updatecustomStatus",
                                               success:function(data){
                                                   if(data.customStatus==1){
                                                       //点击
                                                       $("span[statusId='"+statusId+"']").val(1);
                                                       $("span[statusId='"+statusId+"']").html("<font color='red'>停用</font>");
                                                       $("#"+statusId+"").val(0);
                                                       $("#"+statusId+"").html("启用");
                                                   }else{
                                                       $("span[statusId='"+statusId+"']").val(0);
                                                       $("span[statusId='"+statusId+"']").html("启用");
                                                       $("#"+statusId+"").val(1);
                                                       $("#"+statusId+"").html("<font color='red'>停用</font>");
                                                   }
                                               }
                                           });
                                       }
                                   }
                });

    页面

        <s:form  id="form" method="post">
            <table align="center" width="960" height="30" border="1px solid" id="find"/>
                <tr align="center" cellpadding="0">
                    <th width="65px">序号</th>
                    <th width="220px">客户名称</th>
                    <th width="200px">法人代表</th>
                    <th width="180px">注册时间</th>
                    <th width="80px">类型</th>
                    <th width="80px">状态</th>
                    <th width="135px">操作</th>
                </tr>
                  <s:iterator value="customsPageSupport.result" var="c" status="status">
                <tr align="center">
                    <td>
                        <s:property value="#status.index+1"/>
                    </td>
                    <td><s:property value="customName"/></td>
                    <td><s:property value="bossName"/></td>
                    <td><s:date name="regDatetime" format="yyyy-MM-dd"/></td>
                    <td><s:property value="customTypeName"/></td>
                    <td>
                        <span id="${c.id}" style="color:green" firststatusId="${c.id }" value="${c.customStatus }"><s:if test="customStatus == 1">启用</s:if>
                        <font color="red"><s:else>停用</s:else></font></span>
                    </td>
                    <td>
                        <span style="cursor:pointer" class="find" findId="${c.id }" >查看</span>                    
                        <span style="cursor:pointer" class="update" updateId="${c.id }">修改</span>
                        <span id="secondspan" style="color:green;cursor:pointer" class="status" statusId="${c.id }" value="${c.customStatus }" customName="${c.customName }"><s:if test="customStatus == 0">启用</s:if>    
                        <font color="red"><s:else>停用</s:else></font></span>                    
                    </td>
                </tr>
            </s:iterator>
  • 相关阅读:
    OkHttp的基本使用方法
    C#中Dictionary小记
    SQL Server表的数据量大小查询
    基于.NET平台常用的框架整理
    JQuery中ajax的相关方法总结
    JQuery中的工具函数总结
    Asp.net MVC 中Controller返回值类型ActionResult
    Plupload文件上传组件使用API
    HTTP 方法:GET 对比 POST
    C#使用简单邮件传输协议(SMTP)发送邮件
  • 原文地址:https://www.cnblogs.com/xuerong/p/5062665.html
Copyright © 2020-2023  润新知