【发布时间】:2009-08-22 04:07:00
【问题描述】:
下面一行是什么意思?
jQuery.post('/codes/handlers/delete_a_question.php',
{ question_id: jQuery(this).attr('question_id') }
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
})
});
我在/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>"
);
如果用户首先通过从 GET 获取 question_id 来单击链接,我会尝试删除问题。但是,我还没有设法让 jQuery 代码工作。我收到以下弹出窗口,但问题没有被删除。
在使用( 解决问题并将$_GET 更改为$_POST 后,我现在弹出this code。
【问题讨论】: