简体   繁体   中英

open jquery-ui dialog based on ajax response

I'm trying to open a jquery-ui dialog when the response of checklatestnews.php meets the condition rec != "0". I created a test checklatestnews.php file where the response is always "1", yet a jquery-ui dialog will still not open. Any help would be appreciated.

<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>
$.post("checklatesnews.php", {action: "check"}, function(response) {
    .....
    $("#dialog").dialog("open");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM