Add a meta tag to your home page (s) to save the value of the current application path from the host (bit ~ represents).
In your Javascript, create a function that will resolve the prefix path using the contents of the meta tag.
Edit
Example on request: -
Put this code in the chapter section of the main pages: -
<meta id="meta.AppDomainAppVirtualPath"
name="AppDomainAppVirtualPath" value="<%=HttpRuntime.AppDomainAppVirtualPath%>" />
Your javascript has this feature enabled: -
function resolveUrl(url)
{
if (url.charAt(0) == "~")
{
if (!resolveUrl.appPath)
{
var meta = document.getElementById('meta.AppDomainAppVirtualPath');
resolveUrl.appPath = meta ? meta .getAttribute("content") : '/';
}
if (resolveUrl.appPath == '/')
return url.slice(1, url.length;
else
return resolveUrl.appPath + url.slice(1, url.length);
}
else
{
return url;
}
}
Now your line of code: -
$.getJSON(resolveUrl("~/Postcode/GetAddressResults/") + $get("SearchPostcode").value, null, function(data) {