jquery小点

  • ajax请求服务器端数据

$.ajax({
        type : "POST",//请求方式
        url  : "${APP_PATH}/user/deletes",//请求地址
        data :{ id : id },
        success : function(result) {
        		//服务器端成功时,返回操作
       });
  • HTML页面的标签拼接

jquery请求json数据,异步显示数据。采用页面标签的拼接,可以较好的实现数据的异步显示,提升页面的运行效率。在下面的代码中,tableContent 是js的全局变量,将ajax请求的json数据返回到页面后,通过each方法遍历数据,进而进行拼接。其他的HTML标签也可进行相互转换,举一反三。

$.each(users,function(i,user){
               tableContent +='<tr>';
               tableContent +='<td>'+(i+1)+'</td>';
               tableContent +='<td><input type="checkbox"></td>';
               tableContent +='<td>'+user.loginacct+'</td>';
               tableContent +='<td>'+user.username+'</td>';
               tableContent +='<td>'+user.email+'</td>';
               tableContent +='<td>';
               tableContent +='<button type="button" class="btn btn-success btn-xs"><i class=" glyphicon glyphicon-check"></i></button>';
              tableContent +='<button type="button" class="btn btn-primary btn-xs"><i class=" glyphicon glyphicon-pencil"></i></button>';
              tableContent +='<button type="button" class="btn btn-danger btn-xs"><i class=" glyphicon glyphicon-remove"></i></button>';
               tableContent +='</td>';
               tableContent +='</tr>';
});

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值