What does the following line mean?
jQuery.post('/codes/handlers/delete_a_question.php',
{ question_id: jQuery(this).attr('question_id') }
Context in HEAD
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
})
});
My handler in /codes/delete_a_question.php
$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");
HTML
echo ("<a href='#' class='delete_question'"
. " id=question_id'" . $question_id . "'" // to have question_id777
. ">delete</a>"
);
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.
I get now as a popup this code after solving the problem with one (
and changing $_GET
to $_POST
.