With PHP I've saved all my website settings in one file e.g

'baseUrl' => 'http://localhost/thisSite',
'resources' => '../Resources/',  
'templates' => '../Resources/TPL/',

This makes the site very portable. I simply make changes to this one file and
I can move the site to any server.

But I how can I do this with javascript and ajax?
right now I am embedding all the absolute urls in the ajax calls.
As the site grows it will become harder to move it around.
How would you guys solve this issue? Many thanks in advance.

Recommended Answers

All 2 Replies

Can't you use relative urls?

Thank you for your reply.

Yes and No. The directories will later move to a different location(outside the webroot on a linux server).

And again, when that happens I just have to make changes to one file and the all the php code will work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.