var urlstr = base_api + 'index.php'; var prod_id = ''; window.onload = function(){ prod_id = getPar('prod_id'); } function saveBtnDidClicked(){ var user_name = $('#user_name').val(); var name = $('#name').val(); var tel = $('#tel').val(); if (user_name == '') { ZZAlertInfo('用户名不能为空!'); return; } if (name == '') { ZZAlertInfo('真实姓名不能为空!'); return; } if (tel == '') { ZZAlertInfo('手机号不能为空!'); return; } var data = { tp:'supply_dataInfo_execUser', supplier_id:prod_id, user_name:user_name, true_name:name, phone_no:tel, operate:'insert' } $.ajax({ url:urlstr, //请求地址 data:data, type: "post", dataType: "json", success: function (data) { if(data.code == "0"){ console.log(data); ZZAlertInfo(data.info,function(){ window.location.href = './account_list.html?prod_id='+prod_id; }); }else{ ZZAlertInfo(data.info); } } }); } //得到url上的参数 function getPar(par){ var local_url = document.location.href; local_url = decodeURI(local_url); var get = local_url.indexOf(par +"="); if(get == -1){ return false; } var get_par = local_url.slice(par.length + get + 1); var nextPar = get_par.indexOf("&"); if(nextPar != -1){ get_par = get_par.slice(0, nextPar); } return get_par; }