1、引用jQuery.js和jquery.form.js
jquery.form.js:http://malsup.github.io/jquery.form.js
2、html
<form id="form1" runat="server" class="layui-form" action="[接口连接]" target="rfFrame" method="post"><button id="submit" type="submit">保存</button></form><iframe id="rfFrame" name="rfFrame" src="about:blank" style="display:none;"></iframe>
3、js
$("#submit").click(function () {var options = {url: '[接口连接]', //同actiontype: 'post',dataType: 'json',//预计返回json数据beforeSend: function (xhr) {//请求之前},success: function (d) {debugger},complete: function (xhr) {//请求完成},error: function (xhr, status, msg) {}};$("#form1").ajaxSubmit(options);});
随时随地看视频