💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
ajax-post提交前执行预处理 ~~~ // 在ajax-post所在btn上增加subbefore-func的属性,指定预处理函数 ~~~ 在ajax按钮上提交附加内容 ~~~ <button type="submit" class="button btn-primary ajax-post" append-data='{"opt":"save"}' target-form="form-horizontal"> 保存 </button> <button type="submit" class="button btn-primary ajax-post" append-data='{"opt":"save-new"}' target-form="form-horizontal"> 保存并新增 </button> ~~~ 处理ajax返回结果:doDisAjaxReturn(data,that) data组成 * code 是否成功 * url 成功操作跳转地址 * norefresh 成功后不刷新/不跳转 * msg 提示语 例: ~~~ $.get(url).success(function(data){ data.norefresh = 1; doDisAjaxReturn(data); }); ~~~ ------------------------------------------| 代码实现 |------------------------------------------ ~~~ window.doDisAjaxReturn = function(data,that){ var jump_time = 1500; $('.switch-hidden-temp').remove(); if( typeof data!='object' ){ return ; } //zeroModal.closeAll(); unifyExecuteZeroModalFunc('close') if ( data.code*1>0 ) { var updateAlertMsg = data.msg; if( that && $(that).hasClass('no-refresh')){ jump_time = 1000; }else if (data.url) { updateAlertMsg = data.msg;// + ' 页面即将自动跳转~'; } updateAlert(updateAlertMsg,'success'); setTimeout(function(){ var is_not_refresh = 0; if( that && $(that).hasClass('no-refresh') ){ is_not_refresh = 1; }else if( typeof data.norefresh!='undefined' && data.norefresh ){ is_not_refresh = 1; } if( is_not_refresh==1 ){ // 不刷新 $('#top-alert').find('button').click(); }else if (data.url) { if( Think.modal_show==1 ){ if( Think.modal_jump_type=="0" ){ //0:父级页面刷新(默认) parent.location.reload(); }else if( Think.modal_jump_type=="1" ){ //1:父页面跳转 parent.location.href=data.url; } }else{ location.href=data.url; } }else { if( Think.modal_show==1 ){ parent.location.reload(); }else{ location.reload(); } } },jump_time); }else{ updateAlert(data.msg,'error'); setTimeout(function(){ if (data.url) { if( Think.modal_show==1 ){ if( Think.modal_jump_type=="0" ){ //0:父级页面刷新(默认) parent.location.reload(); }else if( Think.modal_jump_type=="1" ){ //1:父页面跳转 parent.location.href=data.url; } }else{ location.href=data.url; } }else{ $('#top-alert').find('button').click(); } },jump_time); } removeBtnDisabled(that); } ~~~