Sometimes the current domain is builds and at other times it's builds.example.com. I would like to call an AJAX request to the same domain as the current one (so that it doesn't violate the same origin policy). How do I find the current domain? If that's not possible, are there any other solutions to the problem?
There's no need to find the current domain. Just use a partial URL:
new Ajax.Request("/partial-url-without-domain", {
method: "post",
parameters: parameters
});