I have 2 separate instances in which I show Data from JavaScript in a heading on my page:
Html:
<h2 id='Fetch_Header' style="color:white; font-family: arial;">
The last time you fetched your games was:<span class="last_fetch" style="font-weight: bold;"></span>
</h2>
jQuery:
$.get('php/FetchGames/LastFetch.php', function (data) {
if (data == "Never") {
var lastdate = data;
$('.last_fetch').html(" " + lastdate);
}
more jQuery:
$.get('php/FetchGames/GetMatchCount.php', function (data) {
MatchCountJson = data;
MatchCountJson_Parsed = JSON.parse(MatchCountJson);
MatchCount = MatchCountJson_Parsed.Int;
//the above JSON is {"Int":72}
});
$('#Fetch_Header').html('Time to apply your MMR, follow the instructions below. Matches left to apply: ' + MatchCount);
However only the former works (The lastdate one).
First Output:
date (as expected)
Second Output:
"Time to apply your MMR, follow the instructions below. Matches left to apply: undefined"
Both of the variables are not null/undefined
, since if I use Console.log
, then the lastdate
is a date, and the Matchcount
is an integer (for example 32).