function RQ_IsOK(oJson){if(oJson.result!="Success"){return false}return true}function RQ_Get(sUrl){var sRet=null;$.ajax({type:"GET",url:sUrl,dataType:"json",async:false,success:function(oJson){if(RQ_IsOK(oJson)){sRet=oJson}}});return sRet}function RQ_Post(sUrl,sData){var bResult=false;$.ajax({type:"POST",url:sUrl,data:sData,async:false,dataType:"json",success:function(oJson){if(RQ_IsOK(oJson)){bResult=true}else{alert("结果: 失败\r\n信息: "+oJson.error)}}});return bResult}function RQ_DoAsynCheckRepeat(oEle,sCmd,check_func){var sn=oEle._ctype_sn;CType_SetChecking(oEle,"正在检查是否存在...");$.ajax({type:"POST",url:"/request.cgi",data:sCmd,async:true,dataType:"json",success:function(oJson){if(sn!=oEle._ctype_sn){return}if(!RQ_IsOK(oJson)){var sErrinfo="检查失败";if(oJson.reason){sErrinfo+=",原因:";sErrinfo+=oJson.reason}CType_SetErrorInfo(oEle,sErrinfo);return}var result=oJson.data.find(check_func);if(result){CType_SetErrorInfo(oEle,"已存在")}else{CType_SetCheckOk(oEle)}}})}function RQ_DoCheckRepeat(oEle,sCmd,check_func){var oJson=RQ_Get("/request.cgi?"+sCmd);if(!oJson){var sErrinfo="检查失败";if(oJson.reason){sErrinfo+=",原因:";sErrinfo+=oJson.reason}CType_SetErrorInfo(oEle,sErrinfo);return false}var result=oJson.data.find(check_func);if(result){CType_SetErrorInfo(oEle,"已存在");return false}CType_SetCheckOk(oEle);return true}function RQ_AsynCheckRepeat(oEle,sCmd,key,sValue){return RQ_DoAsynCheckRepeat(oEle,sCmd,function(item){return item[key]===sValue})}function RQ_CheckRepeat(oEle,sCmd,key,sValue){return RQ_DoCheckRepeat(oEle,sCmd,function(item){return item[key]===sValue})}