【发布时间】:2013-11-08 15:31:21
【问题描述】:
我正在尝试使用 jquery ajax 获取数据,一切正常,我得到了我想要的,但我无法显示它,因为我得到一个 Uncaught TypeError: Cannot read property 'display' of undefined。
这里是代码。有什么想法吗?
/*
* 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>
【问题讨论】:
-
data从 ajax 调用返回时包含什么? -
出于某种原因,我不认为
data是您认为的那样。console.log(data)并分享输出! -
在问题中添加了数据输出。当然IP是假的:D
标签: javascript jquery jquery-ui-dialog