Hi all,
I'm currently working on a new project and I'm trying to make the website completely AJAX based. This would require me to use some different JS files with functions, and to speed things up for the clients I'd like to dynamically include the required JS files.
For Example:
- If I click the registration link, AJAX gets register.php for me and displays it in a div.
- If I click the validation link, AJAX gets validate.php for me and displays it in a div.
- If I click the log in link, AJAX gets login.php for me and displays it in a div.
Now what I want it to do, is that register.php somehow contains a link to register.js and loads that with the AJAX call. This will mean that all the JS files are unloaded untill required by the user.
Is this possible somehow, and if yes, could someone please point me into the right direction, or provide me with an example?
The current code I have it attached. Please remind this is a very early WiP!
What I basically want is to include 'js/register.js' with register.php, 'js/validate.js' with validate.js and 'js/login.js' with login.php, but not when the other files are loaded. (Somewhat like moving line 8, 9 and 10 of index.php so that they aren't always loaded, but only when needed)
I'm currently working on a new project and I'm trying to make the website completely AJAX based. This would require me to use some different JS files with functions, and to speed things up for the clients I'd like to dynamically include the required JS files.
For Example:
- If I click the registration link, AJAX gets register.php for me and displays it in a div.
- If I click the validation link, AJAX gets validate.php for me and displays it in a div.
- If I click the log in link, AJAX gets login.php for me and displays it in a div.
Now what I want it to do, is that register.php somehow contains a link to register.js and loads that with the AJAX call. This will mean that all the JS files are unloaded untill required by the user.
Is this possible somehow, and if yes, could someone please point me into the right direction, or provide me with an example?
The current code I have it attached. Please remind this is a very early WiP!
What I basically want is to include 'js/register.js' with register.php, 'js/validate.js' with validate.js and 'js/login.js' with login.php, but not when the other files are loaded. (Somewhat like moving line 8, 9 and 10 of index.php so that they aren't always loaded, but only when needed)