我使用 JQuery UI 1.8.10 和 jquery latest。
我的代码是:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.js"></script>
<script type="text/javascript" src="/cms/ww.admin/login/login.js"></script>
</head>
<body>
<div id="header"></div>
<?php
if(isset($_REQUEST['login_msg']))
{
require SCRIPTBASE.'cms/ww.incs/login-codes.php';
$login_msg = $_REQUEST['login_msg'];
if(isset($login_msg_codes[$login_msg]))
{
echo '<script>$(function(){$("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>").dialog({modal:true});});</script>';
}
?>
为什么这会给出未定义错误的无法读取属性"3"?
给出错误的文件是jquery-ui.js on line 186
好的,现在我将其更改为:
</head>
<body>
<div id="header"></div>
<div id="login-msg"></div>
<?php
if(isset($_REQUEST['login_msg'])){
require SCRIPTBASE.'cms/ww.incs/login-codes.php';
$login_msg=$_REQUEST['login_msg'];
if(isset($login_msg_codes[$login_msg])){
echo '<script>$(function(){
$("#login-msg").html("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>").dialog({modal:true});});</script>';
}
}
?>
但仍然是相同的错误
这是
来自jQueryUI的一个错误,它使用:d ata选择器(如果你在调用堆栈中上升,你会看到它),它已被弃用/与最新的jQuery不兼容。试试这个jQueryUI:
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/jquery-ui.min.js
这里的例子:
http://jsfiddle.net/techunter/RyUVq/
您发现了错误/不兼容!!
这不起作用 jQuery (1.8.0): http://jsfiddle.net/mZPWS/
较旧的jquery版本(1.7.2)正在工作:http://jsfiddle.net/mZPWS/1/
这可能不是问题的根源,但也许为您的 .dialog() 小部件设置div 可以帮助您。
您的 js 行$("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>").dialog({modal:true}
似乎正在使用一条简单的消息,这在大多数情况下是有效的。
您可以尝试使用此行进行更改吗:
$(function()
{
$("#header") // or any div you have
.html("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>")
.dialog({modal:true});
});
另外,请确保您的"/cms/ww.admin/login/login.js"不是错误的源头,JS错误控制台很容易丢失,并且可以将您指向jquery-UI.js而错误则在其他地方。
我确认不兼容问题。尝试过jquery-1.8.0 和jquery-ui-1.8.4