Tag Archives: reload

Javascript: How to Force a Page Reload and Jump to a Specified Anchor Name in the Process CodeUnit 30 JAN 2012

Anchor names are a great little browser extra that allows you to quickly jump to different sections on a web page courtesy of a handy little # declaration in the page URL. However, these do sometimes get in the way, for instance you want to reload a page’s contents via Javascript, but at the same time want to stay on the section of the page which the user was currently at.

If you specify the anchor name in the URL and to a location equals or reload like you normally would, then unfortunately for you the page won’t reload and will simply jump to the newly specified anchor name – definitely not the behaviour that we want! So how do we get around this then and force the page to first refresh, and then jump to the specified anchor name?

Well actually the answer is pretty simple really. We make use of the optional value of the window.location.reload function to force an actual reload (i.e. ignore the browser cache)!

In practice, first set the current window’s URL (i.e. the page you want to refresh) as the window.location.href value, specifying the anchor name you wish to jump to in the URL. Then call a window.location.reload, specifying true as the function parameter. In code, this would look like:

window.location.href = 'mypagetoreload.htm#jumptosection1';

And that is that. The page will first hard refresh itself and once refreshed, jump through to the specified section.


Ubuntu: How to set up an Apache Virtual Host (vhost) CodeUnit 28 SEP 2011

To set up a virtual host (vhost) under Apache on your Ubuntu server is relatively simple. First you need to create a config file under the /etc/apache2/sites-available directory. A good practice is to name this file the same as the folder you want to use to hold this virtual host’s web pages.

For this example we want to serve up traffic coming in for www.mydomain.com, so we create a file called mydomain:

sudo nano /etc/apache2/sites-available/mydomain

The contents of which looks like this:

<VirtualHost *:80>
DocumentRoot /home/www/mydomain
<Directory />
Options FollowSymLinks
AllowOverride None
<Directory /home/www/mydomain>
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
ServerName mydomain.com
ServerAlias www.mydomain.com

ErrorLog /var/log/apache2/mydomain-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/mydomain-access.log combined

ErrorDocument 404 /error_documents/404.php
ErrorDocument 403 /error_documents/403.php


With the file saved, next we enable the site by running:

sudo a2ensite mydomain

Finally, reload the Apache configuration with:

sudo /etc/init.d/apache2 reload


(And if you are in the process of looking for a hosting server, you may want to check out different web hosting companies first to help you compare and find the most appropriate hosting account for you.)

Ubuntu: How to Reload Apache Configuration without Restarting the Service CodeUnit 18 DEC 2010

Sometimes you make subtle changes to the configuration files of Apache, affecting certain aspects of the server’s performance but not others. To get these changes to the configuration files live, the standard route is to save your changes and restart the Apache service.

Interestingly enough though, this is in actual fact not necessary.


Well thanks to the reload command available to us, reloading the Apache configuration without stopping the service itself is as simple as calling:

sudo /etc/init.d/apache2 reload


jQuery DataTables: How to Reload a Table’s Data CodeUnit 24 MAR 2010

Since my discovery of the awesome jQuery DataTables plug-in I haven’t stopped using it in my projects at it is by far the simplest and cleanest way of delivering feature-rich tables to a user.

Of course, I don’t usually work with static table data, meaning that I use server side processing scripts to load the data to my tables and when I started to employ user selectable data filters not connected to the DataTables object, I realised that I needed to be able to reload the DataTable’s data source at will.

However, simply trying to initialize a DataTable object on an existing DataTable object brings up the error message

DataTables warning: Unable to re-initialise DataTable. Please use the API to make any configuration changes required.

which is needless to say, a good indication that approach is not exactly going to get you anywhere.

The answer lies in exactly what the error message told you – you need to make use of the API calls on the existing DataTable in order to reload its data. So how to do this then?

Well essentially it is a pretty simple solution. First, we check if the known DataTables object exists, in other words, that it is not undefined. If it is undefined, initialize and draw it for the first time. If not, empty it first using the fnClearTable function and then redraw using the fnDraw function – which of course would then reload the updated dataset from the server side processing script.

if (typeof oTable == 'undefined') {
			oTable = $('#commentstable').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"iDisplayLength": 150,
				"bLengthChange": false,
				"sAjaxSource": "datatables_comments_list.php"
			oTable.fnClearTable( 0 );


Related Link: http://datatables.net/index