Welcome Guest, Not a member yet? Register   Sign In
Where do you put your AJAX stuff?
#6

[eluser]eoinmcg[/eluser]
the way i usually do it is extend the controller class (MY_Controller) to have a method to check if the call was AJAX based.

e.g.
Code:
function _is_ajax()
    {
        return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
    }

and then in the relevant controller/method i can take appropriate action
e.g.
Code:
function sample_method()
    {
        if($this->_is_ajax())
        {
            // do you ajax thing here    
        }
        else
        {
            // not an ajax call, reload the page or whatever is needed
        }
    }


Messages In This Thread
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 06:53 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 07:57 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 08:21 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 09:51 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 11:02 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 11:08 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 11:37 AM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 01:16 PM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 02:57 PM
Where do you put your AJAX stuff? - by El Forum - 11-12-2009, 07:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB