Note that there are some explanatory texts on larger screens.

plurals
  1. PODiv hidden by jQuery hide() keeps reappearing
    primarykey
    data
    text
    <p>My application is a message board. When I click on the ans_button, a div appears with the text area for the question. When I submit the question, the message div is once again hidden. If I click remove_button, that specific message is deleted from the inbox and the remaining messages are still displayed. However, as soon as I click a second rmeove_button, the message div appears, when it is supposed to remain hidden. Lastly, if I refresh the page, I can once again click remove once, but the second time breaks the code.</p> <p>I have included code the code wherein I think the problem is contained. However, if need be, I can upload more code. Any suggestions as to where my code is getting caught up would be appreciated. Thanks.</p> <p>Here is my code:</p> <p>HTML:</p> <pre><code>&lt;div class="content" id="messageView"&gt; &lt;!--This content is pulled from a php file--&gt; &lt;!--.ans_button and .remove_button are echoed from php--&gt; &lt;/div&gt;&lt;!--content#messageView--&gt; &lt;div class="content" id="message"&gt; Subject:&lt;input id="subject" type="text"&gt;&lt;br&gt;&lt;br&gt; Question:&lt;textarea id="question"&gt;&lt;/textarea&gt;&lt;br&gt;&lt;br&gt; &lt;input class="submitbutton" id="cancelQ" type="button" value="Cancel" &gt; &lt;input class="submitbutton" id="askQ" type="button" value="Respond" &gt; &lt;/div&gt;&lt;!--content#message--&gt; </code></pre> <p>php:</p> <pre><code>$findMsg = mysqli_query($con,"SELECT * FROM MessageAdmin m, Admin a, User u WHERE (SELECT deptID FROM Admin a WHERE a.deptID = m.programID) AND (SELECT o.threadID FROM OpenMessages o WHERE o.threadID = m.threadID AND o.isClosed = 0 AND (o.answeredBy = 0 OR o.answeredBy = '$curUser') AND (u.userID = o.userID) AND (m.userID = o.userID)) ORDER BY m.timeSent"); if(mysqli_num_rows($findMsg) &gt; 0){ echo "&lt;table id='viewMsg'&gt;"; while($row = mysqli_fetch_array($findMsg)){ echo "&lt;tr&gt;"; echo "&lt;td&gt;" .$row['firstName']." ".$row['lastName']."&lt;/td&gt;"; echo "&lt;td&gt;" .$row['subject']."&lt;/td&gt;"; echo "&lt;td&gt;&lt;button class='ans_button' value='".$row['threadID'].'*'.$row['subject'].'*'.$row['programID']."'&gt;Respond&lt;/button&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;button class='remove_button' value='".$row['threadID'].'*'.$row['timeSent']."'&gt;Delete&lt;/button&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } else echo "&lt;h3&gt;You currently have no messages&lt;/h3&gt;"; </code></pre> <p>jQuery: </p> <pre><code>$(function(){ $("#message").hide(); var request1 = $.ajax({ //fill content of #messageView ... }).success(function(data){ $("#messageView").html(data); }); $('.content').on('click', '.ans_button', function(){ var clicked = $(this); var parts = clicked.val().split("*"); var thread = parts[0]; var subject = parts[1]; var program = parts[2]; $("#subject").val(subject); $("#askQ").on('click', function(){ var question = $("#question").val(); var request2 = $.ajax({ ... }).success(function(data){ if(data == "success"){ $("#message").hide(); $("#question").val(""); } }); }); }); $('.content').on('click', '.remove_button', function(){ var clicked = $(this); var parts = clicked.val().split("*"); var thread = parts[0]; var time = parts[1]; var request3 = $.ajax({ ... }).success(function(data){ if(data == "success"){ $("#message").hide(); $("html").load("messages.php"); $("#messageView").show(); } }); }); }); //end of document.ready </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload