Calling the php variable in JavaScript (numerical value of the php variable)

QuestionsCalling the php variable in JavaScript (numerical value of the php variable)
Jehal Desai Staff asked 4 years ago

I am planning to get the total number of visits to my site that I stored in the variable $total_visit in php, get the numerical value of this variable in javascript and put it in a moving counter.
But when I call the value of the variable, my counter starts counting to infinity and exceeds the number of visits to my site.
The JavaScript code I wrote is as follows:

This is the php code I wrote to call the site statistics:

This code works correctly, but when I call the variables from the JavaScript side, the counter counts to infinity.
I put an image of the output of the above codes:
enter image description here


View on Stack Overflow