Ajax

The following files need including in the head of the document...


    <script src="../Include/Core.js" type="text/javascript"></script>
    <script src="../Include/ssAjax.js" type="text/javascript"></script>
         

Links

We ‘Ajaxify’ a link by giving it the class "ajax", specifying the target for the new content in its lang attribute.


    <a href="Players_Ajax.asp?intTeamID=5" class="ajax" lang="contentbox" onclick="return false;">Manchester United</a>
         

Using the ‘Ajax’ pattern also ensures that any other patterns on the page are applied to the new content as soon as it is loaded. This is done using an array called "arrPatternStack" which stores the ‘initialise’ functions for all the patterns in the page and runs them as soon as the new content is loaded.

For now, (until we have come up with something more elegant), we put onclick="return false;" in the link as well, to avoid the risk associated with a link being clicked before the behaviour has been applied.

Forms

We ‘Ajaxify’ a form by giving it the class "ajax", specifying the target for the new content in its lang attribute. We also need to ensure the form has an id.


    <form method="post" class="ajax" lang="contentbox" id="frmMainInThird" name="frmMainInThird" action="Players_Ajax.asp" onsubmit="return false;">
         

As with links, it will apply any patterns to the new content as soon as it is loaded.

For now, (until we have come up with something more elegant), we put onsubmit="return false;" in the form as well, to avoid the risk associated with a form being submitted before the behaviour has been applied.

It works with both ‘get’ and ‘post’ form requests.