您好我有一个对话框,应该在按钮点击时打开,并在对话框中显示消息'It works'。但我不知道为什么按钮点击后没有出现对话框。谢谢。
这是我的js代码:
function getaddwidget()
{
$.ajax({
type: "POST",
url: "ajax/dashboard.php",
dataType : 'json',
cache: false,
data: {'aktion' : 'add-new-widget'},
success: function(data){
$('#addwidget').html(data.html);
},
error: function(data){
alert('error');
//$('#news').html(data.html);
}
});
}
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$('#addwidget .butt-rahmen').live('click', function(){
if($(this).attr('id') == 'addwidgetId')
$( "#dialog" ).dialog( "open" );
getaddwidget();
});
});
dashboard.php
if($param['aktion'] == 'add-new-widget')
{
$html = '<table width="538" cellspacing="0" cellpadding="0" border="0">
<tr>
<td id="addwidget">
<div id="dialog">
<p>IT WORKS!!!</p>
</div>
</td>
</tr>
</table>';
$return = array(
'status' => 1,
'html' => $html
);
echo json_encode($return);
die();
}