jQuery AJAX Content Section Loader

Posted 5 years, 11 months ago in Code

If you've ever had to do a project recently without a solid template system, it's a pain in the butt. Basically every piece of markup you write needs to be duplicated on each and every page. This means things that often change like links, navigation, headers, and footers have to constantly be updated on every page.

Luckily jQuery and my upcoming JavaScript MVC framework offer some pretty sexy solutions to this problem.

Here is one such solution I worked on to help an associate of mine:

Simply you click a link in the navigation menu and it alerts you with the file you would use with the jQuery $(selector).load(url); function to load the contents of that URL into the contents of the selector. So if you had something like <div id="main-content"></div> you can load the page right into that.

This particular solution is more the quick & dirty way as opposed to my JavaScript MVC framework, but far easier to explain and understand.