Harshil Shah
Harshil Shah

Reputation: 359

How to load a html page in a jquery dialogbox.?

I have created a dialog box and i want to load a HTML page into it h

Upvotes: 0

Views: 11800

Answers (3)

charlietfl
charlietfl

Reputation: 171669

Since you said you've already created the dialog, loading and opening then become as simple as:

$('#dialog').load( url, function(){
    $(this).dialog('open');                   
});

Upvotes: 0

Manse
Manse

Reputation: 38147

Something like this :

var url = "the url";
var dialog = $("#dialog");
if ($("#dialog").length === 0) { // only create if it doesn't exist
    dialog = $('<div id="dialog"></div>').appendTo('body');
}
// load remote content
dialog.load(
url, {}, function(responseText, textStatus, XMLHttpRequest) {
    dialog.dialog({
        // your options
    })
}​)

Upvotes: 0

Patrick Moore
Patrick Moore

Reputation: 13344

Assuming your dialog box is #dialog (<div id="dialog"></div>), this would work:

$.get("url/to/yourpage.html", function(data) {
    $("#dialog").html( data );
});

Upvotes: 6

Related Questions