Fix ajax URL check to run on page load