branko ajzele, senior developer / project manager

Posts / Articles

CodeIgniter, jQuery and Ajax

I have read tens of articles on Ajax. I fully understand the philosophy behind it (or at least I would like to think so). However, until today I have found a way to execute specific function from specific class ba simply calling it from any type of link (button or regular link). Today I stumbled upon this excellent article from Michael Wales. This article is a demonstration of CodeIgniter’s cool architecture and URL handling. It is simply a thing of beauty.

Just imagine you create a link with href attribute like

http://somesiteofmine.domain/index.php/controlername/controlerfunction/

This link executes some Ajax call to controlername.php file containing controlername class and controlerfunction function.

And all it takes is a little jQuery like


$(document).ready(function() {
    $('#ajaxCallSampleLink').click(function(event) {
        event.preventDefault();
        $('#list').load(this.href);
    });

    $('#loading').ajaxStart(function() {
        $(this).show();
    }).ajaxStop(function() {
        $(this).hide();
    });

    $('#list').ajaxStart(function() {
        $(this).hide();
    }).ajaxStop(function() {
        $(this).show();
    });
 });

Please follow the link to Michael Wales original article in order to read full tutorial and download his original files.

  • roy

    nice one…. you don’t have a new link to the tuts?

  • roy

    nice one…. you don’t have a new link to the tuts?

blog comments powered by Disqus