Ajax和javascript传参方式

js方法封装入参数据   把js的以json形式传参

{"sTitle":"操作","mData":"isReview","mRender":function(data,type,full){

                        var info ={'ynBaseCustomerEnterpriseId':full.ynBaseCustomerEnterpriseId,

                           'ynBaseCustomerEnterpriseName':full.ynBaseCustomerEnterpriseName,

                           'ynBaseStaffCompanyId':full.ynBaseStaffCompanyId,

                           'ynBaseStaffCompanyName':full.ynBaseStaffCompanyName,

                           'workId':full.workId};

                       console.log(JSON.stringify(info));

                        if(data==""){

    return"<button class='btn green' data-toggle='modal' data-target='#myModal' οnclick='resetRaty("+JSON.stringify(info)+")'><i class='fafa-plus'></i>新增回访单</button>";

                        }elseif(data=="1"){

                            return '<ahref="">查看回访单</a>';

                        }

                    }}

-----------------------------------------------------------------------------------------------------

传一个字符串变量

vara='<aclass="deletebtndefaultbtn-xsblack"οnclick="position(\''+row.mbMonitorInfomationId+'\')"><iclass="fafa-level-down"></i>定位</a>';

------------------------------------------------------------------


封装js对象转成json字符

functionadd(){

//debugger;

varparams=newObject();

//params.ynBaseStaffCompanyName=$("#ynBaseStaffCompanyId").find("option:selected").text();

params.ynBaseStaffCompanyName=$("#ynBaseStaffCompanyName").val();

params.ynBaseStaffCompanyId=$("#ynBaseStaffCompanyId").val();

params.workId=$("#workId").val();

params.ynBaseCustomerEnterpriseId=$("#ynBaseCustomerEnterpriseId").val();

params.ynBaseCustomerEnterpriseName=$("#ynBaseCustomerEnterpriseName").val();

params.mbContactsUserName=$("#mbContactsUserName").val();

params.mbContactsUserPhone=$("#mbContactsUserPhone").val();

params.mbEvaluationDescription=$("#mbEvaluationDescription").val();

//暂时只有2种评价内容

params.mbCompositeScore=(parseFloat($("#score0").val())*parseFloat($("#mbReturnVisitScoringStandardweight0").val()))+(parseFloat($("#score1").val())*parseFloat($("#mbReturnVisitScoringStandardweight1").val()));

 

varlist=newArray();

varobj1=newObject();

obj1.mbReturnVisitScoringStandardId=$("#mbReturnVisitScoringStandardId0").val();

obj1.mbReturnVisitScoringStandardTotal=$("#mbReturnVisitScoringStandardTotal1").val();

obj1.mbReturnVisitScoringStandardContent=$("#content0").val();

obj1.mbCurrentScore=$("#score0").val();

list.push(obj1);

varobj2=newObject();

obj2.mbReturnVisitScoringStandardId=$("#mbReturnVisitScoringStandardId1").val();

obj2.mbReturnVisitScoringStandardTotal=$("#mbReturnVisitScoringStandardTotal1").val();

obj2.mbReturnVisitScoringStandardContent=$("#content1").val();

obj2.mbCurrentScore=$("#score1").val();

list.push(obj2);

params.list=list;

console.log(JSON.stringify(params));

 

if($("#ynBaseStaffCompanyId").val()==""){

bootbox.alert("请选择抢修单位");

returnfalse;

}

if($("#workId").val()==""){

bootbox.alert("请填写抢修单号");

returnfalse;

}

if($("#ynBaseCustomerEnterpriseId").val()==""){

bootbox.alert("请选择用电企业");

returnfalse;

}

 

$.ajax({

type:"post",

contentType:"application/json",

dataType:"json",

url:"${rc.contextPath}/clientReview/add",

data:JSON.stringify(params),

success:function(data){

if(data.status){

alert("新增成功");

window.location.href="${rc.contextPath}/monitoringCenter/clientReviewPage/clientReview"

}else{

alert(data.errorMessage);

}

}

})

}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值