A very easy and quick way to get a reference is to make use of the alternate link SharePoint will but by default in the head section of every rendered page:
<link type="text/xml" rel="alternate" href="/_vti_bin/spsdisco.aspx" />
var spsdiscoUrl = $("head link[rel='alternate']:eq(0)").attr("href");
spWSUrlPrefix = spsdiscoUrl.substr(0, spsdiscoUrl.length - 13);
url: spWSUrlPrefix + "lists.asmx",
contentType: "text/xml; charset=\"utf-8\""