Table des matières

JQuery

Configuration

$config['javascript_location'] = $config['base_url'].'assets/js/jquery-2.0.3.js';
$config['javascript_ajax_img'] = 'assets/images/ajax-loader.gif';

Exemple Ajax

Contrôleur

<?php
class Ctrl extends \CI_Controller {
function __construct()
   {
        parent::__construct();
        $this->load->library('jsUtils');
   }

	function index(){
	    $this->jsutils->getAndBindTo("#div","click","Ctrl/ajaxGet","#response");
	    $this->jsutils->compile();
	    $this->load->view('test');
	}
	
	function ajaxGet(){
		echo "Exemple de get sur click";
	}
}

Vue

<?php echo $library_src;?>
<?php echo $script_foot;?>
<div id="div">Cliquer sur la div pour afficher la réponse</div>
<fieldset id="response"><legend>Réponse ?</legend></fieldset>

Exécution dans un contrôleur

<?php
class CtrlAjax extends \CI_Controller {
function __construct()
   {
        parent::__construct();
        $this->load->library('jsUtils');
   }

	function index(){
	    $this->jsutils->getAndBindTo("#div","click","Ctrl/ajaxGet","#response");
	    echo $this->jsutils->compile();
	}
	
	function ajaxGet(){
		echo "Exemple de get sur click";
	}
}