开发者

Why cannot I open XHTML content in dialog inside XHTML page?

I have a page with XHTML markup correctly served as XHTML as well. There is a link which if clicked opens a jquery ui dialog and inside the dialog it loads a content from another XHTML page.

The problem is that the content is not loaded inside the dialog window.

The way to fix this issue is by serving the main XHTML page (the one from which the dialog is opened) as HTML (text/html mime type)开发者_StackOverflow.

Why is that? Why won't it work with correctly served XHTML?

Here is my code:

function openDialogByUri(div, uri, title, width, height, buttonsArray) {
    div.dialog({
        title: title,
        width: width,
        height: height,
        position: 'middle',
        resizable: false,
        buttons: buttonsArray
    });
    $.ajax({
        url: uri,
        success: function(response) {
            div.html(response);
        },
        error: function(response) {
            alert(response);
        }
    });
}


You said an XHTML webpage is loaded into the Dialog.

As a valid XHTML website also includes a doctype and <html> and <head> tags placing them in your dialogs XHTML inside the other XHTML page is not valid.

You will either have to use an <iframe> or <object> or only add valid XHTML body content into your jQuery-UI-dialog.

Why this works if the outer HTML is not XHTML depends entirely on the parsing of the browser. This may not be consistent across browsers.

HTML may be parsed in another way, with allowing more syntactical mistakes, probably removing or ignoring inner html and head elements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜