Welcome Guest, Not a member yet? Register   Sign In
Ajax with a custom template

I just wanted to say how much I appreciate the is_ajax_request() method. It makes progressive enhancement a cakewalk with ajax calls:

if($this->input->is_ajax_request()) {

            } else {
                $data = array(
                    'title'     =>  'Sign up for News and Info',
                    'main_content'   =>  'signup_success'
                $this->load->view('template', $data);
I have a template that loads header, sidebar, and footer dynamically:

<div id="container">

        &lt;?php $this->load->view('layout/header'); ?&gt;
        <div id="main-and-sidebar" class="clearfix">    
            <div id="main" role="main" class="left two-thirds clearfix">
                <section id="content">
                    &lt;?php $this->load->view($main_content); ?&gt;
            &lt;?php $this->load->view('layout/sidebar'); ?&gt;
        &lt;?php $this->load->view('layout/footer'); ?&gt;

With jquery I can clear the content and replace with the response from the server:
/*      Signup form         */
    $('#signup-form').submit(function(e) {
        var email = $('#email').val()
        var loading = $('<img class="noshadow" src="/img/loading.gif">');
        $.post('signup', {
            'email' : email
        }, function(response){
        return false;

Messages In This Thread
Ajax with a custom template - by El Forum - 08-03-2011, 02:50 AM

Theme © iAndrew 2016 - Forum software by © MyBB