Is it possible for me to update the values of a data object within my JavaScript code? My JavaScript receives post messages from an iframe, and I need to store this information in the correct objects. However, I am unsure if this can be done on the HTML surface or within the JavaScript environment.
I can use
{{ game.high_score}}
in the HTML to retrieve the high score of a specific game object. But when trying to send values to these objects from JavaScript, I seem to be struggling with the process.
The latest attempt I made was simply:
game.gameData.name = somevalue;
in the JavaScript code, but it appears that this doesn't actually change the global value for this data object (the change is not reflected outside of the JavaScript).
Are there effective methods for handling this issue both within and outside of JavaScript in a Django/Heroku environment?
Edit:
I don't have trouble retrieving data from POST, but rather how to modify a game object's value using a JavaScript-based value. The structure of my game class object is as follows:
class GameInstanceDto:
def __init__(self, base: GameIdentityDto, high_score: int, state: str):
self.base = base,
self.high_score = high_score,
self.state = state
If I can display the game-specific highscore in the HTML using
{{ game.high_score }}
and wish to change its value in JavaScript, I attempted:
game.high_score = "2500";
just to test if the high_score value would update, however, I did not observe any changes.