一旦用户单击按钮,我一直在试图将游戏名称传递给我的 php 函数。这个想法是用户单击一个按钮,该按钮具有其视频游戏名称的值,然后 php 脚本检查该游戏的排名并将该排名返回到 html。我之前已经使发布请求工作,即使在这里我手动将变量名称设置为其中一个游戏来测试它,它也可以工作。请帮忙!
<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>