var mdfund = { create : function(){ data = $('#mdfund').serialize(); $.ajax({ 'type':"POST", 'url':"/admin/data/fund/ac/mdfund/", 'data':data, 'success':mdfund.onsuccessed, 'timeout': 30000, 'error': function(){ $("#alert-info").attr('class','alert alert-error'); $("#alert-info").html("出现错误,请稍后重试"); $('#submit-loading').hide(); return false; }, 'beforeSend': function(){ $("#submit_btn").addClass('disabled'); $("#submit_btn").attr('disabled','disabled'); $('#submit-loading').show(); }, 'complete': function(){ $("#submit_btn").removeClass('disabled'); $("#submit_btn").removeAttr('disabled'); $('#submit-loading').hide(); } }); }, onsuccessed : function(data){ if (typeof(data)=='object') { if(typeof(data.error)!='undefined') { $("#alert-info").attr('class','alert alert-error'); $("#alert-info").html(data.error); return false; } if(typeof(data.success)!='undefined') { $("#alert-info").attr('class','alert alert-success'); $("#alert-info").html("添加成功!"); setTimeout("$('#mdfund-form').modal('hide');",1000); setTimeout("window.location.href = window.location.href",2000); return false; } } else{ $("#alert-info").attr('class','alert alert-error'); $("#alert-info").html('请求中发生错误,请重试'); return false; } }, edit : function(id,fid,uuid,place) { $('#mdfund input[name=id]').val(id); $('#mdfund input[name=fid]').val(fid); $('#mdfund input[name=uuid]').val(uuid); $('#mdfund input[name=place]').val(place); $('#mdfund-form').modal('show'); } }