Or, if you're going to stick with the XHR, at least refactor the code so there is only one XHR that handles both types of URLs.