ユーザーがボタンをクリックするとすぐに、ゲームの名前をphp関数に渡そうとして、壁に頭をぶつけてきました。ユーザーがビデオゲーム名の値を持つボタンをクリックすると、phpスクリプトがそのゲームのランキングをチェックし、そのランキングをhtmlに返します。以前に投稿リクエストを機能させましたが、ここでも変数名をゲームの1つに手動で設定してテストすると、機能します。助けてください!
<script>
$(document).ready(function(){
//global n variable
n = $();
$('#target').click(function(){
//set value of n to the game's name
n = $(this).val();
});
//then send the name as term to my php function to deal with it and return
//the ranking
$.post('getTotal.php', {term: n}, function(data){
//been trying to see if anything comes through for debugging purposes
alert(data);
//commented this out for now, just puts it in the div I left open
//$('#total').html(data);
});
});
</script>