ryy705 Posted October 26, 2009 Share Posted October 26, 2009 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 More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 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 More sharing options...
ryy705 Posted October 29, 2009 Author Share Posted October 29, 2009 Thank you for your reply. Do you propose that I create a json object for every every javascript page? Or are you saying that I should perhaps setup some sort of ajax functionality to retrieve the data from the server? Link to comment https://forums.phpfreaks.com/topic/179081-portability/#findComment-946721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.