Skip to content


Subversion checkout URL

You can clone with
Download ZIP


JHtmlBehavior::keepalive javascript problem #1507

hispid opened this Issue · 9 comments

7 participants


The original javascript looks like:

    $document = JFactory::getDocument();
    $script = '';
    $script .= 'function keepAlive() {';
    $script .= '    var myAjax = new Request({method: "get", url: "index.php"}).send();';
    $script .= '}';
    $script .= ' window.addEvent("domready", function()';
    $script .= '{ keepAlive.periodical(' . $refreshTime . '); }';
    $script .= ');';

The problem is in url address, used in ajax request (it's not SEF friendly, so when in SEF mode this doesn't work).

To resolve the issue, I used JRoute to make url SEF-friendly:

    $document = JFactory::getDocument();
    $script = '';
    $script .= 'function keepAlive() {';
    $script .= '    var myAjax = new Request({method: "get", url: "'.JRoute::_('index.php').'"}).send();';
    $script .= '}';
    $script .= ' window.addEvent("domready", function()';
    $script .= '{ keepAlive.periodical(' . $refreshTime . '); }';
    $script .= ');';

On what environments does this fail? I am unable to reproduce here.


Now I'm using version 2.5.6, but this issue seems to be there from 1.6 branch (I'm tired to fix it each time I update joomla).

To reproduce this you're to enable SEF and wait for about 15 minutes (or you may reduce session time to get it faster). Then you should see the javascript error.

In Google Chrome it looks like:

GET 404 (Not Found) mootools-core.js:485
c.Request.Class.send mootools-core.js:485
i.extend.$owner mootools-core.js:141
keepAlive management.html:21
(anonymous function) mootools-core.js:84


So the environment question means what server and server version are you on, what php version you are on and similar items.
Are you saying it works as expected until your session expires?



PHP Built On: FreeBSD buran.lan 8.2-STABLE FreeBSD 8.2-STABLE #4: Tue Dec 27 23:59:59 MSK 2011 root@buran.lan:/usr/obj/usr/src/sys/buran.2011-05-13 amd64
Database Version: 5.3.6-MariaDB-log
Database Collation: utf8_general_ci
PHP Version: 5.3.13
Web Server: nginx/1.2.0
WebServer to PHP Interface: fpm-fcgi
Joomla! Version: Joomla! 2.5.6 Stable [ Ember ] 19-June-2012 14:00 GMT
Joomla! Platform Version: Joomla Platform 11.4.0 Stable [ Brian Kernighan ] 03-Jan-2012 00:00 GMT
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1

Yes, it works as expected after patch.


The difference is that in original code the request goes to the main page, and after patch the request goes to the current page the user is viewing (because of JRoute using of current option and view variables).


This is language, added by SEF engine. Site is multilingual, maybe that is the reason.

@eddieajau eddieajau closed this

I just got this error on a Joomla! 2.5.18 Stable with all extensions updated.

This is a bug and let me explain why.
What this function does is that it calls index.php before session expires to prevent losing data while writing/editing an article.

 * Keep session alive, for example, while editing or creating an article.
 * @return  void
 * @since   11.1

The problem is that when Joomla has SEO urls, for example:
/products/motorcycles/motard/ is not a real directory and thus it does not contain any index.php file that this function calls by using mootools Request Ajax method. So, in order to do it right, the php function has to route index.php to site root, for instance which is what JRoute::_('index.php') does instead of just having "index.php". So for me this is a bug that I have to correct every time I install a new Joomla site or doing a core update.


I just tried executing the bellow code
var myAjax = new Request({method: "get", url: "index.php"}).send(); which is there, inside session alive

Yes indeed it sends the request to an inner index.php path. But in my case it worked since the inner depth was 2 and yet the request URL was like /index.php/index.php, where index.php was there multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.