以下行是什麼意思?瞭解jQuery的一行
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>"
);
我想刪除一個問題,如果用戶點擊首先由gett創建一個鏈接從GET獲取question_id。但是,我沒有設法讓jQuery代碼工作。我得到以下彈出窗口並且問題沒有被刪除。
我現在得到一個彈出this code解決問題後,一個(
和改變$_GET
爲$_POST
。
**我應該如何處理數據?** Question_id?這對我來說似乎沒有必要。 – 2009-08-22 04:46:58
只有post函數的第一個參數是強制性的。所以,如果你不需要問題ID參數,然後刪除它。 – rahul 2009-08-22 04:48:18