I can’t help but think that this is a duplicate, but if it is, I can’t seem to find the doppelganger.
I’m just starting to learn Python (focusing on Pylons) and I’d like to know if there is a way to determine if a call to a controller is done asynchronously or not. In PHP it would look something like this:
function isAjax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
}
Is there one that works well for all of Python, or is there perhaps one that works very well only in Pylons?
Thanks in advance!
To directly translate that code to python using pylons you would do something along the lines of:
where request is the request object passed to the controller.