使用ajax发布时无法显示加载

时间:2016-12-08 13:10:57

标签: javascript jquery css ajax

初始化进程时,我无法显示加载div。我有另一个bootstrap模式显示,在ajax请求后,我想显示加载器并模糊引导模式和背景。这里的问题是,目前我的加载器被发送到模态的后面。

#loader {
    bottom: 0;
    height: 175px;
    left: 0;
    margin: auto;
    position: absolute;
    right: 0;
    top: 0;
    width: 175px;
    position:relative;
}
#loader {
    bottom: 0;
    height: 175px;
    left: 0;
    margin: auto;
    position: absolute;
    right: 0;
    top: 0;
    width: 175px;
}
<div id="loader" style='display:none'>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
    <div class="lading"></div>
</div>
<div id="reg-form" class="modal fade" tabindex="-1">
    <div class="modal-dialog modal-lg">
</div
</div>
$('form#register-form').submit(function(e) {
    var formInfo = {};
    document.getElementById("loader").style.display = "block";

    $.post("ajax_handler/ajax_handler.php", {
        action: 'register_user',
        param: formInfo,
        pos: lastNode.id
    }, function(response, status) {  
        try {
            jsonResponse = JSON.parse(response);              
        } catch(err) {
            alert("Sorry, we are not able to fulfill the request. Your query cannot be processed right now.");           
            return;
        }

        if (jsonResponse.result == false) {  
            document.getElementById("loader").style.display = "none";
            alert("Sorry. " + jsonResponse.msg);
        }             

        disableGraphKey(true);
    });
    return false;
});

0 个答案:

没有答案