0

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>

1 Answer 1

1
$.post("checklatesnews.php", {action: "check"}, function(response) {
    .....
    $("#dialog").dialog("open");
});
Sign up to request clarification or add additional context in comments.

9 Comments

$("#dialog").dialog("open"); is opening a blank dialogue but works. how do i echo the .html(data);
Then set data before open: $("#dialog").html(data).dialog("open")
I changed $("#dialog").dialog("open"); to $("#dialog").html(data).dialog("open"); but now the dialogue is not opening
Check the data variable... What it contain? From where you get data? console.log(data)
If you get data from response and response type is json, then $("#dialog").html(response.data).dialog("open");
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.