Welcome Guest, Not a member yet? Register   Sign In
jQuery and CodeIgniter
#1

[eluser]jhcthulhu[/eluser]
Greetings!

I'm a new CodeIgniter user and fairly new to web apps in general, and I'm having some problems with refreshing a div within a page using jQuery.

I've ready through dozens of wonderful help posts here but I haven't found one specific to my problem. I've read and tried net.tuts on jQuery/AJAX, and used a mutant version of

http://www.mrforbes.com/blog/2009/01/a-q...-tutorial/

but I can't seem to get things to refresh.

I have a page built and populated with catalog elements from a database, and each item onClick sends a value to my jQuery .load(); function, that in theory should fetch a new single set of data from the database relating to that same item, and return it to a loaded view in a div on my main page. I.e. click on item 1201 in the main page, and the div containing a view populated by just that item's row in the database will refresh with each new item clicked on.

I've checked the function and it is loading in the proper variable value from the item clicked.
I've loaded the function string it generates manually calling it directly in the browser and the 'test' view that controller function loads has properly loaded the correct array from the database.
In fireBug, the link generated by the jQuery .load() turns up red, but manually loading the link does generate the correct data.

Two problems: one: onClick simply isn't loading anything into the correct div, it stays blank (it does load the test header, so I know the view is being called into the main page correctly). Two: I'd like it to load the first item from the current set if there's no value for the details div.

I hope this isn't too noobie or extensive a question Smile Thanks for your time!

ControllerSadthis is the function handling the details request from onClick:
Code:
function details1200($model_number){
        
    $results['details'] = $this->Mod_1200->getModelNumber($model_number);

    $this->load->vars($results);
    $this->load->view('test', $results);
    }

This is the jQuery functionSadI've removed my huge mess of testing with .post and .ajax)
Code:
function get_model_number(model_number) {
    var p = {};
    p = model_number;
     $('#details_results').load(<?php echo base_url();?> + 'details1200/' + p);    
    }

And here is the part of view that is loading another view that contains the details:
Code:
<div id="details">
                &lt;?php $this->load->view('test.php'); ?&gt;
            </div>

..and the test details page:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;

[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
//&lt;![CDATA[
    base_url = '&lt;?php base_url();?&gt;';
//]]>
[removed]
&lt;/head&gt;
&lt;body&gt;
<div id="details_results">
    <h1>test page</h1>

    
</div>
&lt;/body&gt;
&lt;/html&gt;

Once again, in theory, a user click on an item from the main page catalog, the javascript loads the test view page with the function details1200 with the specific item # that was clicked, then the view test #details div gets refreshed and displayed on the main page.

Thank you all!
-J


Messages In This Thread
jQuery and CodeIgniter - by El Forum - 08-28-2010, 10:12 PM
jQuery and CodeIgniter - by El Forum - 08-28-2010, 11:23 PM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 12:18 AM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 01:00 AM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 10:10 AM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 02:15 PM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 03:32 PM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 04:07 PM
jQuery and CodeIgniter - by El Forum - 08-29-2010, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB