Blogger Information
Blog 6
fans 341
comment 0
visits 5864
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
AJAX异步提交
大家讲道理的博客
Original
1017 people have browsed it
<script>
$(function(){
    $(".submit_btn").click(function(){
        if(!window.FormData){ 
            alert('your brower is too old');
            return false;
        }
        var $this=$(this);
        var thisform=$this.parents('form');
        var checkform_o=true;
        $("input[required]").each(function(){
            if($.trim($(this).val())=="" && checkform_o){
                $(this).focus();
                checkform_o=false;
            }
        });
        if(!checkform_o){
            return false;
        }
        $.ajax({
            url:location.href,
            data:new FormData(thisform[0]),
            type:'post',
            cache:false,
            processData: false,
            contentType: false,
            dataType:'json',
            success:function(data){
                if(data.status==1){
                    layer.msg('修改成功', {icon: 1});
                }else{
                    layer.msg(data.msg, {icon: 2});
                }
            },
            error:function(){
                layer.msg("网络错误", {icon: 2});
            }
        });
    });
});
</script>

今天在做后台提交时,遇到AJAX提交不能够提交图***字段的数据,特别记录下。

 data:new FormData(thisform[0]),
            type:'post',
            cache:false,
            processData: false,
            contentType: false,

重点是这几行。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post