打开基于ajax响应的jquery-ui对话框

时间:2016-05-28 19:38:16

标签: javascript php jquery ajax jquery-ui

当checklatestnews.php的响应符合条件rec!=“0”时,我正在尝试打开jquery-ui对话框。我创建了一个测试checklatestnews.php文件,其中响应始终为“1”,但jquery-ui对话框仍然无法打开。任何帮助,将不胜感激。

<div id="dialog">

<script type="text/javascript">

 $("#dialog").dialog(
   {
    bgiframe: true,
    autoOpen: false,
    height: 100,
    modal: true
   }
);
</script>

<script type="text/javascript">

   var check_latestnews;
function CheckForLatestNewsNow() {
    var str="chklatestnews=true";
    jQuery.ajax({
            type: "POST",
            url: "checklatestnews.php",
            data: str,
            cache: false,
            success: function(res){
                if(res != "0") {


 $("#dialog").html(response).dialog("open");

                }

            }
    });
}
check_latestnews = setInterval(CheckForLatestNewsNow, 5000);
</script>

1 个答案:

答案 0 :(得分:1)

$.post("checklatesnews.php", {action: "check"}, function(response) {
    .....
    $("#dialog").dialog("open");
});