怎么實現表單提交后不重新刷新當前頁面
<form name='form1' id='form1' action='/xbcw/cw/xx_xx.action' method='post'>
<input type="button" id="btnSubmit" name="btnSubmit" value="保存" onclick="addKp()" class="Button2" />
<input type="button" id="btnSubmit" name="btnSubmit" value="下一步" onclick="doAddCwKpSubmit()" class="Button2" />
</form>
當我點擊保存提交FORM表單后,如何讓當前頁面維持不變(即不刷新當前頁)?
在FORM表單后添加一個iframe
<iframe id="rfFrame" name="rfFrame" src="about:blank" style="display:none;"></iframe>
點保存提交事件里面需要將target改為iframe的名字:
JS:document.forms[0].target="rfFrame";
JQuery:$("#f2").attr("target","rfFrame");
這樣即提交了FORM保存了數據,頁面也不會跳轉.