WP_Query
has a $post_count
variable.
http://codex.wordpress.org/Class_Reference/WP_Query#Properties
Just pass that with the script using wp_localize_script
WP_Query
has a $post_count
variable.
http://codex.wordpress.org/Class_Reference/WP_Query#Properties
Just pass that with the script using wp_localize_script