Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have this function that sets an achievement in my database and returns infos about the achievement to be displayed on a bootstrap 3 modal.

JavaScript
function setAchievement(idAchievement){
    $.ajax({
        url: "http://localhost:8080/licenta/setAchievement",
        data:{"idAchievement":idAchievement}
    }).then(function(data) {
        if (data.description != "null"){ // if update was made
            $("#description").text(data.description); // set the divs with infos received about the achievement
            $("#xp-gained").text(data.xpGained);
        }
    });
    $("#achievementsModal").modal("show");  // display the modal
    $( "#continue" ).click(function() {  // close the modal when the continue button is clicked
        $("#achievementsModal").modal("hide");
    });
}

This works just fine when I call the function only once like this:

JavaScript
setAchievement(0);  

But sometimes the user can do 2-3 achievements so I need to display 2-3 modals(when i close one, the next one should open).
JavaScript
setAchievement(0);
setAchievement(1);
setAchievement(2);


Here comes my problem, even if my database updates with all 3 achievements , on the view page only one modal opens(for the first setAchievement(0) call).

I can't see a workaround for this problem. Any tips would be great. Thanks.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900