admin管理员组文章数量:1302520
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.
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: [email protected]</li>
</ul>
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.
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: [email protected]</li>
</ul>
Share
edited Oct 29, 2013 at 13:18
Karim N Gorjux
asked Oct 29, 2013 at 12:57
Karim N GorjuxKarim N Gorjux
3,03324 silver badges29 bronze badges
3
-
2
what does
data
contain when it's returned from the ajax call? – ithcy Commented Oct 29, 2013 at 13:04 -
For some reason I don't think
data
is what you think it is.console.log(data)
and share the output! – tymeJV Commented Oct 29, 2013 at 13:06 - Added the data output at the question. Of course the IP is a fake :D – Karim N Gorjux Commented Oct 29, 2013 at 13:19
2 Answers
Reset to default 7Try wrapping your data HTML inside a container, either on the backend or the frontend:
var dialog = $('<div/>').html(data);
I'm not sure .dialog()
will work on multiple document fragments (you have a <p>
and a <ul>
inline). $(data)
would be an array with 2 elements which is not what .dialog()
expects.
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? With Sublime you can show this empty line.
本文标签: javascriptjQuery UI Uncaught TypeError Cannot read property 39display39 of undefinedStack Overflow
版权声明:本文标题:javascript - jQuery UI: Uncaught TypeError: Cannot read property 'display' of undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741680109a2392118.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论