Welcome Guest, Not a member yet? Register   Sign In
Session problem when using jQuery.load() function
#1

[eluser]FordEscort[/eluser]
Hi all.

I'm using IE 8.0.6001.18702 and Firefox 3.5.3.
I have a problem with CI's session when dealing with jQuery.load method.
In Firefox everything is OK but in IE it seems that the session is not recognized.
Here's a simplified sample code of my application :

controllers/test_session.php :

Code:
<?php

    class Test_session extends Controller
    {
        function __construct()
        {
            parent::Controller();
        }

        function index()
        {
            $this->load->view('test_session');
        }

        /**
         * La fonction qui changera la valeur en session et chargera le résultat dans le div
         */
        function testLoad()
        {
            $Val = $this->session->userdata('testVal');
            if (!empty($Val))
            {
                $Val++;
            } else
            {
                $Val = 1;
            }
            echo $Val;
            $this->session->set_userdata('testVal', $Val);
        }

    }

    /* Fin du fichier test_session.php */
    /* Emplacement: ./system/application/controllers/test_session.php */


views/test_session.php :

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]
    &lt;/head&gt;
    &lt;body&gt;
    <div id="testDiv"></div>
    [removed]
    $(document).ready(function(){
        $('#test_link').click(function(){
            $('#testDiv').load('&lt;?php echo site_url('test_session/testLoad'); ?&gt;');
            return false;
        });
    });
    [removed]
    <a href="#" id="test_link">Test</a>
    &lt;/body&gt;
    &lt;/html&gt;


Normally when I click on $('#test_link') the value displayed should increment but in IE it doesn't work.

Can you help me please.

Thanks.
#2

[eluser]pistolPete[/eluser]
How do you know about a session failure in IE?
Did you try using a network sniffer (e.g. Wireshark) to see the request and the response?
#3

[eluser]FordEscort[/eluser]
I've not yet tried sniffing but I tried the same application without framework and it worked like a charm.
#4

[eluser]FordEscort[/eluser]
I noticed that when I change something in the testLoad() function it's not applied even if I refresh the page in IE. Perhaps IE put the data in cache when it's loaded by jQuery.load() ?
It's strange when I don't use the framework the changes are applied.

Help please :-S
#5

[eluser]FordEscort[/eluser]
It's OK. I found the solution in the jQuery doc :
Quote:Note: Keep in mind that Internet Explorer caches the loaded file, so you should pass some extra random GET parameter to prevent caching if you plan to call this function more than once




Theme © iAndrew 2016 - Forum software by © MyBB