I'm accessing a back-end server through a wordpress. I put the question here because it is more java related than wordpress related. After I initialize, I get a big chunk of JSON formatted data in my console. I WANT IT.
{"HeroP":0,"Coins":1,"LeadP":0,"Exp":10},"currency1":0,"currency2":0,"currency3":0,"currency4":0,"currency5":0,"currency6":0,"displayName":"testuser":{}}
This happens because of:
function accountDetailsResponse(response) {
console.log(JSON.stringify(response));
That javascript is found in my header.php, not the various js files I have saved.
I love seeing the server working. But I want to isolate "Coins" or "displayName" as a variable. Then I want to define an element in my html like this:
- Coins
- displayName
- Exp - or whatever. Any/all of those things in the JSON
This way, when someone logs in, it automatically shows their display name, Coins, or any other variable in a nice tidy list without the unnecessary JSON value that isn't relevant to them.
Further details: The console spits out nearly everything for debugging purposes. Server test data, API initialization data, the works. Likewise, more than one person will log into this server, so displayName "testuser" will change to displayName "billybob" or "jimmyjoe", whoever logs in.
I'm super new at coding with javascript, and am barely literate. I apologize if the question isn't formatted correctly. I've been figuring things out on my own, but this one definitely has me stuck. I can't seem to parse the string, isolate a variable, and display it in html!