Welcome Guest, Not a member yet? Register   Sign In
Getting undefined variables and calls to undefined functions.
#1

[eluser]Unknown[/eluser]
Hi! I'm a beginner at using CI so please bear with me. I came across a problem in a project I am doing. I've tried searching but never found similar topics. I hope someone can give me a quick answer to my questions.

I am trying to load some data into a view and inject the resulting html + data into my main view via AJAX. What's happening is that when I try to view this injected html, I get a bunch of PHP errors, all undefined variables and calls to undefined CI functions.

I have included stripped down versions (just the related parts) of my code here:

Here is my controller:

Code:
<?php

class My_loader extends Controller {

    function My_loader()
    {
        parent::Controller();
    }
    
    function get_wrkload() {
        $id = $this->input->post('wid');
        $this->load->model('e_log_model');
        $data['record'] = $this->e_log_model->getWorkLoad($id);
        $this->load->view('record',$data);
    }
?>

My model:
Code:
<?php

class E_log_model extends Model {

    function E_log_model(){
        parent::Model();
        $this->load->database();
        $this->load->library('encrypt');
    }
        function getWorkLoad($id) {
        $query = $this->db->get('tbl_workload');
        $this->db->where('id', $id);
        if ($query->result() < 0) {
            return false;
        } else {
            return $query->result();
        }
    }

The jQuery AJAX:
Code:
$('.edit').click(function() {
            wid = $(this).attr("value");
            $.ajax({
                type: "POST",
                url: "&lt;?php echo site_url("my_loader/get_wrkload");?&gt;",
                data: "wid="+wid,
                success: function(data,msg){
                    $('#result-area').load("&lt;?php echo base_url(); ?&gt;system/application/views/record.php");
                }
            });
            $('#edit-dialog').dialog('open');    
        });

In my view I have a div id'ed #result-area where the data is supposed to load. The record.php view is simply a fragment that wil be injected into the #result-area container. It's kinda long to post the whole code so here's part of it:
Code:
&lt;?php print_r($cat_list); ?&gt;
        <table class="add-wrk-tbl ui-widget">
            <tbody>
                <tr>
                    <td class="wl-label ui-widget-content ui-corner-all">
                        Priority&lt;?php echo $record['priority'];?&gt;
                    </td>
                    <td class="wl-field ui-widget-content ui-corner-all">
                        &lt;?php
                            $att0 = 'id="e_priority" class="{validate:{required:true}} ui-widget-content ui-corner-all"';
                            echo form_dropdown('e_priority', $priority_list, $record['wrk_priority'], $att0);
                        ?&gt;
                    </td>
..... and so on

I assure you it is a properly constructed table. I've used the same in some other part of my project and it works well.

I do realize that the problem is that data I passed to the record view through my controller doesn't seem to exist, and the CI functions I used here are being ignored.

What could probably cause this? Is there a better way to achieve the same result?


Messages In This Thread
Getting undefined variables and calls to undefined functions. - by El Forum - 02-02-2010, 02:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB