팝업을 가져올 수 없습니다 : 그것을 수정는 jQuery를 대화 내가 여기에 링크를 "찬성 투표"를 눌러 후 팝업하기 위해 jQuery를 대화 상자를 얻기 위해 노력하고
http://www.problemio.com는 (I는이 예에서 작업하고 있었다 그것은 나를 위해 작동하지 않았기 때문에 : http://blog.nemikor.com/2009/04/08/basic-usage-of-the-jquery-ui-dialog/)
다음이 작동하지 않습니다 :)
<script type="text/javascript">
$(document).ready(function()
{
var $dialog = $('.dialog')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
$('.vote_up').click(function()
{
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();
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
}
else
{
alert ("not");
}
//alert(JSON.stringify(data));
}
});
//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>
을 나는 또한이있는 다른 jQuery를 기능이이 코드보다도 내가 지금까지 가지고있는 jQuery 코드입니다 documentOnready 체크. 그게 중요할까요? 대화 상자 코드를 전역으로 설정해야합니까? 그렇다면 어떻게해야합니까?
어쨌든 내가 지금 설치 한 대화 상자를 어떻게 열 수 있습니까?
감사합니다.
이 내 jQuery를 수입을 변경 :<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.16/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" />
코드가 정상적으로 보입니다. 'alert ("errr"); 경고가 표시됩니까? – BNL
먼저 대화 상자를 초기화 한 후 다음을 수행하여 대화 상자가 나타나는지 확인하십시오. '$ dialog.dialog ('open ');'. 그 후에 아약스 응답이 문제인지 더 자세히 진단 할 수 있습니다. –
@BNL 예, 경고가 표시됩니다. 내가 얻는 오류는 대화 상자 개체에 관한 것입니다. 그리고 다른 사람들은 내 질문에 추가 한 일부 수입을 제안했는데 오류도 있습니다. – GeekedOut