Improved AJAX and URL checking