.html but text does not appear after ajax request

After ajax call, I add a div bufto some message box, but the text appears after opening the dialog box. In Chrome, firefox, IE 8, this works fine, but not in ie 7.


Edited: I have a dialog box that opens when I click a link. Then I make an ajax request and get a message. This message should appear in the dialog box (in some divs) after clicking the button in the dialog box. But in the message, IE7 appears after opening the dialog box.

$("#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:

When a link is clicked, a function is called createDialog("")without an argument. After ajax request, get a message and call createDialog(buf). But I think this is a bad decision. 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
    });
}
+5
1

.html() IE6-8

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

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

All Articles