0

I want this div displayed on my page whenever there is a "Y" in the database.

<div style="width:100%; height:41px; position:fixed; bottom:0px; background:#184888;     padding:22px 0 0 15px;  bottom:0px; z-index:9997; box-shadow: 10px 10px 5px #888888;" id="hide">
<div id="message" style="z-index:9998;">  </div>

How would I make it so that the div is displayed and not displayed without refreshing the page. Basically I have to see if it is a "Y" in the database, and if it is, display the div. If an "N" is in the database do not display the div, using JavaScript.

I am currently using this function to see check the database for a value.

$('div#checkcheck').load('../bar/check.php/check.php');
1
  • What error do you get? Commented Feb 13, 2014 at 17:06

4 Answers 4

2

Pass an anonymous function to your jQuery load. This will be able to catch the value from check.php

$('div#checkcheck').load('../bar/check.php/check.php', function(response) {
  //do something with that response
});
Sign up to request clarification or add additional context in comments.

Comments

0

Send an ajax request to your server. Let your php code check for the 'Y' in database. Your server call will return a json.

Use that json in javascript to check for 'Y' or'N' and then show/hide your div.

Comments

0
$.get('../bar/check.php/check.php', function(response) {
    $('div#checkcheck')[response === 'Y' ? 'show' : 'hide']();
});

Comments

0

Try this:

$.getJSON('../bar/check.php/check.php', function(res){
    if(res === 'Y')
    {
        $('div').show();
    }
    else
    {
        $('div').hide();
    }
});

Comments

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.