weixin_33717298 2017-12-13 10:47 采纳率: 0%
浏览 35

在ajax之前不显示模态

I have an Javascript on click event that will loop all of the json to store it to database with ajax and before that i already add some modal to popup before the loop is running. but the problem is the modal doesn't pop up before the loop is running and pop up after the loop is running this is my code this i my javascript

            $.fn.dataTable.ext.buttons.Mapping = {
                text: 'Save To Database',
                action: function (e, dt, node, config) {

                    $('#modal-respondent-upload').modal('show');
                    var filename = $("#xlf").val().replace("C:\\fakepath\\", "");

                    var obj = jQuery.parseJSON(output);
                    $.each(obj.hasil, function (key, value) {
                        var dataRespondent = {
                            json: JSON.stringify(value),
                            importSessionDataID: 1
                        }
                        console.log(dataRespondent);
                        var respondentID = simpleAjaxRequest(dataRespondent, "/UploadExcel/CreateRespondent/", "Import Respondent Data");
                    });                    
                }
            };

function simpleAjaxRequest(data, url, text) {
    var id = 0;
    $.ajax({
        type: 'POST',
        url: url,
        data: data,
        async: false,
        success: function (data) {
            //moveProgressBar(10, text);
            id = data;
        }

    });
    return id;
}

and my modal is like this

<div class="modal fade" role="dialog" id="modal-respondent-upload">
    <div class="modal-dialog">
        <div class="modal-content">
            <h1><span id="kondisi-data-modal">0</span>/<span id="jumlah-data-modal">0</span></h1>
        </div>
    </div>
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB动图问题
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题