Question:

Javascript question?

by  |  earlier

0 LIKES UnLike

Hi Guys,

How would I change this line of code from..

url: 'http://10.0.0.1/ajaxListener.php

to something more dynamic? is there a $_SERVER['SERVER_ADDR]

variable of some sort I could use? This code is going to be transfered to a different server so, this line of code cannot be static

Thanks,

Jimmie

 Tags:

   Report

2 ANSWERS


  1. this is an AJAX question really, I'm not much for AJAX, but if all else fails, you may want to look at decomposing the URL for example:

    window.location.hostname holds the hostname of the server the HTML document was requested from.  

    and window.location.pathname holds the path after the / in the URL (including the /, I believe).


  2. Hard-coded IP addresses are a bad idea in general. Why not use the IP name of the domain and allow DNS to do the resolution of the address, or have I missed some pertinent point about your setup?
You're reading: Javascript question?

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.