使用jquery.form.js 进行表单提交,通过回调函数实现页面互动功能。
2017-03-24 16:50
1366 查看
使用jquery.form.js 进行表单提交,通过回调函数实现页面互动功能。
<script>
$(document).ready(function() {
//alert("document");
var options = {
//target: '#output2', // target element(s) to be updated with server response
type: "post",
url : "xxx.action/sub",
success: afterAdd
};
$('#addForm').ajaxForm(options);
$('#addForm').submit(function() {
$(this).ajaxSubmit();
return false;
});
});
function afterAdd(responseText, statusText, xhr, $form) {
var obj = eval('(' + responseText + ')');
console.log(obj);
if (obj.aa == "1"){
alert("数据已经添加,不能重复添加");
}else{
alert("false");
alert("添加成功");
}
}
</script>
<script>
$(document).ready(function() {
//alert("document");
var options = {
//target: '#output2', // target element(s) to be updated with server response
type: "post",
url : "xxx.action/sub",
success: afterAdd
};
$('#addForm').ajaxForm(options);
$('#addForm').submit(function() {
$(this).ajaxSubmit();
return false;
});
});
function afterAdd(responseText, statusText, xhr, $form) {
var obj = eval('(' + responseText + ')');
console.log(obj);
if (obj.aa == "1"){
alert("数据已经添加,不能重复添加");
}else{
alert("false");
alert("添加成功");
}
}
</script>
相关文章推荐
- 使用jquery.form.js 进行表单提交,通过回调函数实现页面互动
- jQuery通过jquery.form.js插件使用AJAX提交Form表单
- 基于jQuery通过jQuery.form.js插件使用ajax提交form表单
- 【文件上传】使用jquery.form.js来实现表单提交
- 使用jquery.form.js实现form表单无刷新提交简单示例
- 基于jQuery通过jQuery.form.js插件使用ajax提交form表单
- 使用jquery-form.js实现form表单的异步提交
- Play FrameWork 使用jquery.form.js实现无刷新提交带文件的表单
- 使用jquery.form.js实现form表单无刷新提交简单示例
- ASP.NET jQuery 实例11 通过使用jQuery validation插件简单实现用户登录页面验证功能
- 使用jQuery.form插件,实现完美的表单异步提交【转发】
- 使用jQuery.form插件,实现完美的表单异步提交
- ASP.NET jQuery 食谱11 (通过使用jQuery validation插件简单实现用户登录页面验证功能)
- 使用jQuery.form插件实现表单异步提交+上传文件
- iframe标签实现form表单提交无页面刷新(不需要js)---解析
- $.ajax 和 jquery.form.js实现表单异步提交
- 同一个页面内实现html+js表单提交输出功能
- Jquery通过Ajax方式来提交Form表单的具体实现
- ASP.NET jQuery 食谱12 (通过使用jQuery validation插件简单实现用户注册页面验证功能)
- 使用jQuery.form插件,实现完美的表单异步提交