Javascript equivalent to $_SERVER['http_host']

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Javascript equivalent to $_SERVER['http_host']

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

window.location ?
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

lol, I didn't think that one through did I?
Post Reply