0

Problem: Tried reloading results from MySQL in index.php, using JavaScript. But for some reason it didn't work, I followed a stackoverflow answer.

When clicking the ID 'yes', nothing happens. I have defnied the jQuery liberally, and getting 0 errors in console.

Question

What have I done wrong? How do I fix it?

Basically I want the JavaScript to reload / refresh results from mySQL, if there are new ones when you click the ID 'yes'.

                echo '<div id="messages">';
                while($row = $fetch->fetch( PDO::FETCH_ASSOC )) {
                        echo 
                        '<div class="background">'.$row['email'].' <span style="margin-left: 10px;"><font color="#ff0000">UNANSWERED</font></span><span id="right"><a href="index.php?recover='.$row['recover_id'].'">Read More</a></span></div><br />
                        ';
                }
                echo '</div>';

The HTML

<span id="yes">RELOAD</span>

The JS

<script type="text/javascript">
$(document).ready(function(){
    $("#yes").click(function(){
        $("#message").eq(0).load("index.php");
    })
})
</script>   

Followed this: Reload MySQL data inside a DIV using Ajax

1 Answer 1

1

Your div in the first code block is #messages

Your JS in the second code block looks for #message

Need to line those up

Sign up to request clarification or add additional context in comments.

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.