Fix a couple of Ajax related path issues

  - Include context path when generating page specific JS
  - Include context path when making Ajax requests
  - Fix Ajax path matching (previously renderVersion was being set to
    "ajax")

fixes #1591 
Thanks for changing it, no idea if using a separate server would work, and as I was reading the changes on this PR, I kept wondering when I was going to read code that would handle separate servers :)