问题背景
提交保存按钮后,需要提示并返回列表页面,使用以下代码,发现提示消失很快,一闪而过
问题解决
layer.msg('提交成功',{time:1000},function(){ window.location.href='<%=path %>/physicalExamination/physicalExamList.action'; });
给layer.msg加时长,并且将跳转方法放到function()里面
完整代码
function saveForm() { $("#save_btn").attr("disabled","disabled"); var formObject = {}; var formArray =$("#jmExaminationSave").serializeArray(); $.each(formArray,function(i,item){ formObject[item.name] = item.value; }); formObject.jmDocID=$("#jmDocID").val(); var url ="<%=path %>/physicalExamination/jmExaminationSave.action"; $.ajax({ url: url, type: "post", data: JSON.stringify(formObject), contentType : 'application/json', dataType: "json", success: function (data) { $("#save_btn").removeAttr("disabled"); if (data.code == 0) { layer.msg('提交成功',{time:1000},function(){ window.location.href='<%=path %>/physicalExamination/physicalExamList.action'; }); } }, error : function() { $("#save_btn").removeAttr("disabled"); layer.open({ title: '提示' ,content: '操作异常!' }); } }); }