简体   繁体   English

jQuery UI:未捕获的TypeError:无法读取未定义的属性“display”

[英]jQuery UI: Uncaught TypeError: Cannot read property 'display' of undefined

I'm trying to get data using jquery ajax, everything works good and I get what I want, but I can't display it because I get a Uncaught TypeError: Cannot read property 'display' of undefined. 我正在尝试使用jquery ajax获取数据,一切正常,我得到了我想要的东西,但我无法显示它因为我得到一个未捕获的TypeError:无法读取未定义的属性'display'。

Here the code. 这里的代码。 Any idea? 任何的想法?

/*
 * Get the data from the ajax call and display a dialog
 */

function CreateDialog(email) {

    // get the data from the ajax call
    var promise = AjaxSubscribe(email)

    // if data are available, show the dialog
    promise.success(function (data) { 
        // data is a simple html code
        var dialog = $(data);

        // can't setup the dialog! Error
        // Uncaught TypeError: Cannot read property 'display' of undefined 
        dialog.dialog({
            autoOpen: false,
            modal: true,
            show: {
                effect: "blind",
                duration: 1000
            },
            hide: {
                effect: "explode",
                duration: 1000
            }
        });

        dialog.dialog( "open" );
        return false;
    });
}

This is the output of data 这是数据的输出

 console.log(data)

 <p>Data debugging</p>
 <ul>
   <li>Ip address: 193.125.139.18</li>
   <li>Country Name: Italy</li>
   <li>Country Code: IT</li>
   <li>Email: anemail@gmail.com</li>
 </ul>

Try wrapping your data HTML inside a container, either on the backend or the frontend: 尝试将数据HTML包装在容器中,位于后端或前端:

var dialog = $('<div/>').html(data);

I'm not sure .dialog() will work on multiple document fragments (you have a <p> and a <ul> inline). 我不确定.dialog()会处理多个文档片段(你有一个<p>和一个<ul>内联)。 $(data) would be an array with 2 elements which is not what .dialog() expects. $(data)将是一个包含2个元素的数组,而不是.dialog()期望的。

Be sure do you not have an empty line at the end of your file. 请确保文件末尾没有空行。 Some editor like Vim add automatically an empty line to respect the POSIX standard Why would Vim add a new line at the end of a file? 像Vim这样的编辑器自动添加一个空行来尊重POSIX标准为什么Vim会在文件末尾添加一个新行? With Sublime you can show this empty line. 使用Sublime,您可以显示此空行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery UI:未捕获的TypeError:无法读取未定义的属性&#39;nodeType&#39; - jQuery UI : Uncaught TypeError: Cannot read property 'nodeType' of undefined JQuery UI Slider Uncaught TypeError:无法读取未定义的属性“addClass” - JQuery UI Slider Uncaught TypeError: Cannot read property 'addClass' of undefined 无法动态加载jQuery UI-未捕获的TypeError:无法读取未定义的属性&#39;ui&#39; - Unable to load jQuery UI dynamically - Uncaught TypeError: Cannot read property 'ui' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性“ ui5” - Uncaught (in promise) TypeError: Cannot read property 'ui5' of undefined Kendo ui:未捕获的类型错误:无法读取未定义的属性“toLowerCase” - Kendo ui: Uncaught TypeError: Cannot read property 'toLowerCase' of undefined jquery-ui.js:12443未捕获的TypeError:无法读取undefined的属性&#39;apply&#39; - jquery-ui.js:12443 Uncaught TypeError: Cannot read property 'apply' of undefined jquery-ui.js:8056 Uncaught TypeError: Cannot read property 'left' of undefined - jquery-ui.js:8056 Uncaught TypeError: Cannot read property 'left' of undefined 未捕获的类型错误:尝试显示数据时无法读取未定义的属性“0” - Uncaught TypeError: Cannot read property '0' of undefined when trying to display data jQuery nestedSortable:未捕获的TypeError:无法读取未定义的属性“匹配” - Jquery nestedSortable: Uncaught TypeError: Cannot read property 'match' of undefined 未捕获的TypeError:无法读取未定义jQuery可拖动+可排序的属性“替换” - Uncaught TypeError: Cannot read property 'replace' of undefined jQuery draggable + sortable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM