簡體   English   中英

jQuery UI:未捕獲的TypeError:無法讀取未定義的屬性“display”

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

我正在嘗試使用jquery ajax獲取數據,一切正常,我得到了我想要的東西,但我無法顯示它因為我得到一個未捕獲的TypeError:無法讀取未定義的屬性'display'。

這里的代碼。 任何的想法?

/*
 * 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;
    });
}

這是數據的輸出

 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>

嘗試將數據HTML包裝在容器中,位於后端或前端:

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

我不確定.dialog()會處理多個文檔片段(你有一個<p>和一個<ul>內聯)。 $(data)將是一個包含2個元素的數組,而不是.dialog()期望的。

請確保文件末尾沒有空行。 像Vim這樣的編輯器自動添加一個空行來尊重POSIX標准為什么Vim會在文件末尾添加一個新行? 使用Sublime,您可以顯示此空行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM