Home > CodeIgniter, jQuery > CodeIgniter, jQuery and Ajax

CodeIgniter, jQuery and Ajax

September 18th, 2008

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.

Interesting? Share it!
  • Digg
  • del.icio.us
  • Google
  • Technorati
  • Facebook
  • TwitThis
  • description

Related articles

CodeIgniter, jQuery , ,

  1. roy
    December 11th, 2008 at 14:21 | #1

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

  1. No trackbacks yet.