0
我有一个游戏,我想保存高分。如何在ajax调用中存储全局变量的值?
这是我在做什么现在:
/* high score stuff */
var score = 0;
var highscore = 0;
var scoreelement = $('#highscoredisplay');
//showing high score
function calchighscore(){
highscore = $.get('highscore');
$.ajax({
url:'index.html',
type: 'get',
dataType: 'html',
success: function(data){
jQuery('#highscoredisplay')
}
//set score to wincount
score = wincount;
if(score > highscore){
highscore = score;
}
showscore();
}
我的ajax调用不工作,那是因为我不知道如何进行适当的调用。现在我可以增加我的高分,但是高分不会在退出游戏后得到保存。
任何人都可以帮我吗?我想我需要使用我的高分榜,但我不知道如何。我一直在寻找很多例子,但我找不到我正在寻找的东西,或者我只是不明白我在找什么......
在此先感谢!