我正在做一個遊戲,我需要通過發佈請求發送一些變量到排行榜頁面。如何添加更多變量到這個AJAX帖子...?
這是我目前郵編:
var toDatabase = confirm('Do you want to save your score to the database?');
if (toDatabase) {
$.post("leaderboards.php", {"Level1": "Level1"}, function() {
window.location.href="leaderboards.php";
});
} else {
$.post("gameL2.php", {"Level1": "Level1"}, function() {
window.location.href='gameL2.php';
});
}
這上面的代碼鏈接到leaderboards.php
文件是一個我希望增加更多的變數太多。如何才能做到這一點?我要添加一對新的大括號嗎?
這裏的例子可能會有幫助:https://api.jquery.com/jQuery.ajax/#entry-examples – showdev