ajax的表单提交

阅读次数: 6,629

  • A+
所属分类:建站
/* 表单提交 start */
        function ajax_form(){

            // 整理数据
            var form = new FormData(document.getElementById("user_form"));
//             var req = new XMLHttpRequest();
//             req.open("post", "${pageContext.request.contextPath}/public/testupload", false);
//             req.send(form);
                console.log(form);
            $.ajax({
                url:AgentUrl+"/index.php?act=goods&op=add",
                type:"post",
                data:form,
                processData:false,
                contentType:false,
                success:function(msg){
                    // window.clearInterval(timer);
                    // console.log("over..");
                    alert(JSON.stringify(msg));
//                    window.location.href = './user_list.html';
                },
                error:function(e){
                    alert("错误!!");
                    window.clearInterval(timer);
                }
            });
        }
        /* 表单提交 end */

不多说了,直接看代码吧

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: