Added code to finish up ajax request to check database