fixed bugs in js and wrote in ajax request to /count