ajax 编辑保存table

前端之家收集整理的这篇文章主要介绍了ajax 编辑保存table前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
function save(){
   var url = "${ctx}/repayment/saveRepaymentPlan";
   var table = document.getElementById("contentTableTbody");
   $("#btnSubmit").attr("disabled","true");
   loading('正在提交,请稍等...');
   var jsonStr = "[";
   for(var i=0; i<table.rows.length; i++){
      // 标id  var bid = $("#contentTableTbody tr:eq("+i+")").find("input[name^='bid']").val();
      // 代扣管理费  var managementCost = $("#contentTableTbody tr:eq("+i+")").find("input[name^='managementCost']").val();
      // 还款计划id  var planId = $("#contentTableTbody tr:eq("+i+")").find("input[name^='planId']").val();
      //参数JSON  jsonStr = jsonStr + "{\"bid\":\""+bid+"\",\"managementCost\":\""+managementCost+"\",\"planId\":\""+planId+"\"},"  }
   jsonStr = jsonStr.substring(0,jsonStr.length-1)+"]"  $.ajax({
      url:url,type:'post',data:{"afterPayPlan":jsonStr},dataType:'JSON',success:function(result){
         if(result.status == '20000102'){
            alert(result.msg);  window.location.href="";
         }else{
            alert(result.msg);
            $("#btnSubmit").attr("disabled","false");
            //loading();  }
      },error:function(result){
         alert("提交失败,请联系管理员!");
         $("#btnSubmit").attr("disabled","false");
         window.location.href="";
         //loading();  }
   });
   //alert(jsonStr); };

猜你在找的Ajax相关文章