Javascript – Best practice: JSON/JQuery/Codeigniter with different tabs

codeigniter, javascript, jquery, json, php

I am creating a calendar list system, that has tabbed dates on top, with data listings below it. I think I know how to use JSON and load the data with JQUERY into a div, but I am not sure how to load it dynamically, based on which tab I selected.

How would I do this, and what's the best practice? I am using the codeignitor framework.

Best Solution

Add an event listener to each tab that calls a function which will control what to send to the ajax function.

The tab itself would store the date somewhere on it, for an example lets say your tab is set up like this

<ul>   <li><span class="something">08/09</span></li></ul>

Now have the event listener bind to .something, which calls a function that passes the date of the tab onto the php back end via ajax.

called_by_event(e){   call_ajax_fnc(this.innerHTML);}

The back end then interprets the date and returns the valid information.