Added function to detect AJAX requests