使用jquery.form.js 进行表单提交,通过回调函数实现页面互动功能。

来源:互联网 发布:无翼鸟app软件下载 编辑:程序博客网 时间:2024/05/16 13:03
使用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> 
0 0
原创粉丝点击