Jump to content

Portability


ryy705

Recommended Posts

Hello,

 

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.

Link to comment
https://forums.phpfreaks.com/topic/179081-portability/
Share on other sites

Have your functions accept json objects as arguments, you can then set sane defaults within each function or have them overridden. You could even have them overidden by a global json object but I think thats going a bit far.

 

Javascript is pretty notorious for this sort of thing (IMO), its hard to keep your code modular. You could take a look at the mootools framework. Its basic premise is to help modularize your code (amongst other things).

Link to comment
https://forums.phpfreaks.com/topic/179081-portability/#findComment-944977
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.