form表单提价插件

1.<form id="addData" method="post" action="{pigcms{:U('Community/oneRegister')}" class="h-form" enctype="multipart/form-data">
</form>

2.<script src="{pigcms{$static_path}community/js/jquery.form.js"></script>
3.$(function () {
$('#addData').ajaxForm({
beforeSubmit: checkForm, // 此方法主要是提交前执行的方法
success: complete, // 这是提交后的方法
dataType: 'json'
});
});

function checkForm() {}
function complete(data) {
if (data.status == 200) {
alert(data.message);
window.location.href = "{pigcms{:U('index')}";
} else if (data.status == 300) {
//先登录
alert(data.message);
window.location.href = "{pigcms{:U('Login/index')}";
} else if (data.status == 400) {
//已经注册
alert(data.message);
window.location.href = "{pigcms{:U('index')}";
} else {
//字段非法
alert(data.message);
}
}
 
原文地址:https://www.cnblogs.com/wangyuyanhello/p/7985410.html