function onsuccess(响应)显示隐藏div上的整个页面

时间:2016-03-19 13:22:13

标签: javascript php html

每次上传图片时,都会在隐藏的div上显示整个页面,如截图所示

the webpage before uploadafter uploaded 我觉得下面的脚本标签有问题,因为如果我删除了响应变量,它就不会再显示重复的页面了,但也没有更多的响应,应该会在页面上显示

任何帮助将不胜感激!

这里是代码:

<form action="" method="POST" id="uploadimg" enctype="multipart/form-data">
                    <div class="form-group col-md-6"><br />
                        <label class="col-md-4">Product thumbnail:</label><input type="file" name="thumb" id="thumb"/><br />
                        <label class="col-md-4">Profile picture01:</label><input type="file" name="file01"/><br />
                        <label class="col-md-4">Profile picture02:</label><input type="file" name="file02"/><br />
                        <label class="col-md-4">Profile picture03:</label><input type="file" name="file03"/><br />
                        <label class="col-md-4">Profile picture04:</label><input type="file" name="file04"/><br />
                        <label class="col-md-4">Farmer's photo:</label><input type="file" name="farmer"/><br /><br />

                        <input class="btn btn-warning btn-sm " type="submit" value="Upload" name="submit"/><br /><br />
                    </div>

                    <div class="form-group col-md-6">
                        <div id="loader">
                            <center><img src="images/loading.gif" /></center>
                        </div>
                        <div id="onsuccessmsg"></div>
                    </div>
                </form>


<script>
$(document).ready(function(){
    function onsuccess(response){
        $("#loader").hide();
        $("#onsuccessmsg").html('</b><div id="msg">'+response+'</div>');
    }

    $("#uploadimg").on('submit',function(){
        $("#loader").show();
        var options={
        success: onsuccess
        };

    $(this).ajaxSubmit(options);
    return false;
    });
});
</script>

0 个答案:

没有答案