Note that there are some explanatory texts on larger screens.

plurals
  1. POTo understand a line of jQuery
    text
    copied!<p>What does the following line mean?</p> <pre><code>jQuery.post('/codes/handlers/delete_a_question.php', { question_id: jQuery(this).attr('question_id') } </code></pre> <p>Context in HEAD,</p> <pre><code>jQuery('a.delete_question').live('click', function(){ jQuery.post('/codes/handlers/delete_a_question.php', { question_id: jQuery(this).attr('question_id') }, function(data){ alert ("Output of the delete.php -page: " + data ); // `data` is probably unnecessary }) }); </code></pre> <p>My handler in <code>/codes/delete_a_question.php</code>,</p> <pre><code>$dbconn = pg_connect("host=localhost port=5432 dbname=noa user=noa password=123"); $result = pg_prepare ( $dbconn, "delete_question_query", "DELETE FROM questions WHERE question_id = $1" ); $result = pg_execute ( $dbconn, "delete_question_query", array ( $_GET['question_id'] ) ); header( "Location: /codes/index.php?successful_removal"); </code></pre> <p>HTML,</p> <pre><code> echo ("&lt;a href='#' class='delete_question'" . " id=question_id'" . $question_id . "'" // to have question_id777 . "&gt;delete&lt;/a&gt;" ); </code></pre> <p>I am trying to remove a question if the user clicks a link first by getting the question_id from GET. However, I have not managed to get the jQuery code to work. I get the following popup and the question is not removed.</p> <p>I get now as a popup <a href="http://dpaste.com/83881/" rel="nofollow noreferrer">this code</a> after solving the problem with one <code>(</code> and changing <code>$_GET</code> to <code>$_POST</code>.</p>
 

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