Below code works on localhost, but not on live server.
MAIN EDIT:
Only 1 thing remains which is not working:
after function saveScore() add: var close = function() { $('#overlay').remove(); };
var close = function() { $('#overlay').remove(); };
after success: function (data) {} remove last comma
success: function (data) {}