Page 1 of 1

Javascript equivalent to $_SERVER['http_host']

Posted: Tue Jul 25, 2006 7:18 am
by Skittlewidth
Is there a Javascript equivalent to $_SERVER['http_host'] or $_SERVER[''SERVER_ADDR' ]?
i.e for use with:

Code: Select all

http.open('get', 'http://www.the domain.com/survey/rpc.php?action='+action);
I have an ajax script that can occasionally fail because if a user types in http://www.thedomain.com it resolves to http://thedomain.com but if they've clicked a link from say another site, it correctly loads as http://www.thedomain.com.

The XMLHttpRequest gets confused and won't work for both. It would also be nice not to have to change the domain settings when I test the script locally.

Posted: Tue Jul 25, 2006 7:31 am
by Chris Corbyn
window.location ?

Posted: Wed Jul 26, 2006 7:11 am
by Skittlewidth
lol, I didn't think that one through did I?