Yes, you do an AJAX request. You want to use jQuery AJAX which makes it very easy.
For protection against a person doing thousands of attacks the best way is to only allow a given number of requests from the same IP address within a given amount of time - this is of course done server-side.
You could also make your script for checking credentials very slow so that it's not so easy to hammer your website with attempts. If you put a pause into your script of 3-5 seconds it will take a long time do many attempts. But of course, if someone makes many simultaneous attempts to your website it might not have the great effect without any other security measure at the same time.