【发布时间】:2011-10-06 03:26:06
【问题描述】:
我是 jQuery 新手,我正在尝试向用户打开一个弹出对话框,以防出现
error : function(data)
到目前为止,我在 jQuery 代码中的内容是:
<script type="text/javascript">
$(document).ready(function()
{
var $dialog = $('<div></div>')
.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
$('.vote_up').click(function()
{
alert ( "test: " + $(this).attr("data-problem_id") );
problem_id = $(this).attr("data-problem_id");
var dataString = 'problem_id='+ problem_id + '&vote=+';
$.ajax({
type: "POST",
url: "/problems/vote.php",
dataType: "json",
data: dataString,
success: function(data)
{
// ? :)
alert (data);
},
error : function(data)
{
//alert("ajax error, json: " + data.responseText);
errorMessage = data.responseText;
if ( errorMessage == "not_logged_in" )
{
alert ("errr");
// Try to create the popup that asks user to log in.
//$(this).dialog();
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
}
else
{
alert ("not");
}
//alert(JSON.stringify(data));
//for (var i = 0, l = json.length; i < l; ++i)
//{
// alert (json[i]);
//}
}
});
//Return false to prevent page navigation
return false;
});
$('.vote_down').click(function()
{
alert("down");
problem_id = $(this).attr("data-problem_id");
var dataString = 'problem_id='+ problem_id + '&vote=-';
//Return false to prevent page navigation
return false;
});
});
</script>
我收到一个 JavaScript 错误,指出 Object 没有方法对话框。这对我来说似乎是希腊语:)
如果你点击“投票”链接,就会出现错误:http://www.problemio.com
我该如何解决这个问题?我可以让那个对话框出现吗?它将要求人们登录网站或注册。
谢谢!!
【问题讨论】:
标签: javascript jquery ajax