How to get the total number of posts (in PHP) and pass it to Javascript?

I have an AJAX call that pulls the next page of posts on my home.php template. Now I want the total number of posts as a variable in the javascript file, so that I can use it in an if-statement to hide the loadmore button. The script is localised as follows:

How can I get the total number of posts as a variable in the javascript file?