• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Modifying sessions with Javascript

#11
[eluser]toopay[/eluser]
What make you confused? Clearly, the log say that the HTTP request is must be done synchronous, thats why you failed with this code
Code:
// This not work
xmlhttp.open('GET', '<?php echo base_url(); ?>languagesetup/setlanguage/english', true);
// This should work
xmlhttp.open('GET', '<?php echo base_url(); ?>languagesetup/setlanguage/english', false);

HTTP is Synchronous: a client issues a request and waits for the corresponding response before anything else is done, while Asynchronous HTTP Request Processing is a technique that allows you to process a single HTTP request using non-blocking I/O(input/output), and it does not wait for the response but instead continues any further necessary processing!

#12
[eluser]Jilimay[/eluser]
Arg, forget it, I was just being stupid ... Confusedhut:

Thanks for your help everybody !

#13
[eluser]gbar[/eluser]
Hi, I need to return to this discussion for some clarification.
I developed a multilingual system, based on the passage of the names of languages, in variables.

This system that I found here, is certainly much better, and it allows me to begin to familiarize yourself with ajax.

Having to adapt it to an existing system, I had to make some small change, only in the languagesetup controller.

Everything would work fine, I only have a small problem that I believe is not caused by my changes.

In practice the problem is that once I click on one of the flags, the page becomes completely empty, i see only the background color.

If I press the F5 key or I refresh the page, the page is reloaded with the new language correctly.

Place code here, if anyone can give me a tip.

Thank you.

The controller languagesetup:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Languagesetup extends CI_controller
    {
        public function __construct()
        {
            parent::__construct();    
        }
    
        public function set_language($lang = 'english')
        {
            $ref =& get_instance();
            $ref->session->set_userdata('lang', $lang);
        }
    }

The view:
Code:
function switchToEnglish()
{
    var xmlhttp =  new XMLHttpRequest();
    xmlhttp.open('GET', '<?php echo base_url(); ?>admin/commons/languagesetup/set_language/english', false);
    xmlhttp.send();
    document.body[removed] = xmlhttp.responseText;
    return true;
}
function switchToItalian()
{
    var xmlhttp =  new XMLHttpRequest();
    xmlhttp.open('GET', '<?php echo base_url(); ?>admin/commons/languagesetup/set_language/italian', false);
    xmlhttp.send();
    document.body[removed] = xmlhttp.responseText;
    return true;
}

I call the two ajax function inside an onclick event handler, inside a link with href setting to #

Also, i use jquery 1.5.1. I have implemented ajax.googleapis, but i have the same problem. Thank's


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.