简体   繁体   中英

.html work, but text not appear after ajax request

After ajax call, I'm appending div buf to some message box, but text appears after the dialog is reopened. On Chrome, firefox, IE 8, this works fine, but not in ie 7.


Edited: I have dialog window wich open on clicking a link. Then i do ajax request and get a message. This message should appear in dialog window (in some div) after clicking a button in the dialog. But in IE7 message appears after dialog window is reopened.

$("#promised_pay_dialog").dialog({
        buttons: {
            "some button": function(){
                if ($('#confirm').is(':checked')) {
                    $.ajax({
                        url: 'ajax/promisedPayment',
                        type: "POST",
                        data: {
                            subsId:$("#sid").val()
                        },
                        success: function(buf){
                            $('#message_box').html(buf);
                            return false;
                        }
                    });
                }
                else {
                    alert("some message");
                }
            },
            "some button": function() {
                $(this).dialog("close");
            }
        },
        show: {
            effect: "blind",
            duration: 1000
        },
        hide: {
            effect: "explode",
            duration: 1000
        },
        modal: true,
        resizable: false,
        width: 550,
        height: 250
    });

solved the problem, but not satisfactorily:

On clicking the link, call function createDialog("") with no argument. After ajax request, receive message and call createDialog(buf) . But i think it's no good solution. Any ideas?

function createDialog(mess){
    $('#message_box').html(mess);
    $("#promised_pay_dialog").dialog({
        buttons: {
            "some button": function(){
                if ($('#confirm').is(':checked')) {
                    $.ajax({
                        url: 'ajax/promisedPayment',
                        type: "POST",
                        data: {
                            subsId:$("#sid").val()
                        },
                        cache:false,
                        success: function(buf){
                            createDialog(buf);
                        }
                    });
                }
                else {
                    alert("some message");
                }
            },
            "some button": function() {
                $(this).dialog("close");
            }
        },
        show: {
            effect: "blind",
            duration: 1000
        },
        hide: {
            effect: "blind",
            duration: 1000
        },
        modal: true,
        resizable: false,
        width: 550,
        height: 250
    });
}

.html() is knows for issues with IE6-8

Try replacing the following

$('#message_box').html(buf);

with

$('#message_box').empty().html(buf);

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