我无法让我的代码正常工作。我想发送' next_question_id'的内容。按钮到我的php文件next_question.php。然后在div" question_text"中显示输出。我做错了什么.. :)
Javascript
function myFunction(clicked_id) {
var button = clicked_id
var next_question_id = document.getElementById(button).getAttribute("next_question_id");
$.post('next_question.php', {
postnextquestionid: next_question_id
},
function(data) {
$('#question_text').html(data);
});
}

PHP
<?php
include 'conn.php';
$next_question_id = $_POST['next_question_id'];
echo $next_question_id;
?>
答案 0 :(得分:6)
你的帖子var将是postnextquestionid
,而不是next_question_id
$next_question_id = $_POST['postnextquestionid'];