简体   繁体   中英

Why does this work with Firefox but not Chrome or IE?

I have the following code that runs when the process_2banner button is clicked on a html page. This code does what is supposed to do when using Firefox. When using Chrome and Internet Explorer the ajax code is called but the div spinner_block does not show/hide as the code intends to. Strangely enough it works if I open firebug in Chrome and place a breakpoint right before the ajax call (after the .css("display","block") statement. The spinner_box <div> shows, and then after the ajax call returns, it hides.

Can you see what is wrong here? Thank you very much! Andres

$('#process_2banner').on("click",function() {
    var postdata = "lead_id="+rowId;   //needs to include the pidm of the user clicking the button
    $('#spinner_box').css("display","block");
    $('#spinner_box').html('Wait, we are processing the record..');
    $('#spinner_box').css("display","block");
    $.ajax({type: "POST",
        url: "insert_srwordpress.php",
        data:postdata,
        success:function(result) {
            if (result.isOk == false) { 
                alert('Some error occurred while writing Banner') } 
            else { 
                $('#spinner_box').hide();
            }
        },
        async: false});
});

The response result is an string in format JSON? May you need parse the JSON before use it?

Example:

var jData = $.parseJSON(result);

if (jData.isOk === false) {

  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM