0

I just wonder if anyone can fix/explain this

i have simple script like this, which is working fine

$(document).on("click", '#toexcel', function () {
    if (exp_sql) {
        $.ajax({
            url: "xtras/toExcel.php",
            dataType: 'json',
            data: "sql=" + encodeURIComponent(exp_sql),
            beforeSend: function () {
                $("#wait").show();
            },
            complete: function () {
                $("#wait").hide();
            },
            success: function (response) {
                exp_sql = '';
                window.location.href = response.url;
            }
        });
    };
});

my wait img implemented like:

<img src="css/wait.gif" id="wait" style="display: none;" />

My problem is that image never shows in Chrome on successful respond, despite if i need to wait few seconds before Excel download start. but it shows if response is unsuccessful (problem with php script it calls) - why is that?


BTW

i tried to put $("#wait").hide(); in success - makes no difference...


should i mention that this is internal domain website not hosted on internet?

Chrome version - Version 27.0.1453.110 m - and in Firefox it works correctly!

4

1 回答 1

0

尝试这个:

   $(document).on("click", '#toexcel', function () {
    if (exp_sql) {
        $("#wait").show();
        $.ajax({
            url: "xtras/toExcel.php",
            dataType: 'json',
            data: "sql=" + encodeURIComponent(exp_sql),
            async: false,
            success: function (response) {
                $("#wait").hide();
                exp_sql = '';
                window.location.href = response.url;
            }
        });
    };
});
于 2013-06-12T09:32:19.810 回答