Ajax Islands Solution
Download AjaxCSSJS here.
You can load JavaScript and CSS files dynamically (on-demand) by means of AjaxCSSJS which is the 4th class of AjaxIslands (the 2nd and 3ed classes are not released yet!).
You can load your CSS or JavaScript files this way:
new AjaxCSSJS('css/grid.css', 'css'); new AjaxCSSJS('js/ajaxform.js', 'js');
You load a JavaScript to use it! don't you?
I mean usually you call a function or make an object after loading a JavaScript file. In this example you are going to make an AjaxForm object like this:
new AjaxCSSJS('js/ajaxform.js', 'js'); var af = new AjaxForm("frmProfile", "profile.act.php", "loader1.gif", "profileBoard");
But your second line of code will fail!
The browser try to load the ajaxform.js asynchronously! It means that the browser won't wait for the file to be loaded and will continue executing the rest of the code. So the second line which is trying to instantiate the AjaxForm will run before the file is loaded!!!
Don't worry! AjaxCSSJS class has a nice feature to solve this problem too!
You can pass a function as 3ed argument to the constructor of the class. This function will be executed as soon as the browser loads the file. So we should change the code this way:
new AjaxCSSJS('js/ajaxform.js', 'js', function() { var af = new AjaxForm("frmProfile", "profile.act.php", "loader1.gif", "profileBoard"); });
2 comments:
I have been visiting various blogs for my term papers writing research. I have found your blog to be quite useful. Keep updating your blog with valuable information... Regards
to hear that :)
I continue updating my blog...
Just a little busy these days.
Post a Comment