Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Actinia's Avatar
    Join Date
    Feb 2007
    Location
    Essex, UK
    Posts
    250
    Thanks
    1
    Thanked 23 Times in 22 Posts

    A beginner's luck with Ajax: including one file text in another

    I am posting this thread to encourage those who have not used Ajax before. It is much easier than I thought it would be.

    I have many lines at the begining and the end of all my pages that are constant. The obvious solution is to use a Server-Side Include for these. However, the VLE I am using (WebCT Vista) will not permit these.

    Hitherto, I have either used loading a javascript file which writes the appropriate HTML (for the top lines), and a set of lines in the Dreamweaver Template (for the bottom lines).

    Having read the article on 'How do I include one HTML file in another' at Boutell.com, I though that Ajax would do it better, and indeed it has.

    Boutell provides the javascript function clientSideInclude. All I needed to do was:

    • Include this function in my preliminary javasacript file;
    • Add two calls to this function in my onload function;
    • Insert two named DIVs, one at the top and one at the bottom.

    It worked like a dream.

    In the onload function I have the lines:

    clientSideInclude('BottomLines', '../../Includes/BottomLines.htm');
    clientSideInclude('TopLines', '../../Includes/TopLines.htm');

    and in the file I have

    <div id="TopLines"><div> at the top, and

    <div id="BottomLines"><div> at the bottom.

    This has the great advantage that I can edit these included files without Dreamweaver telling me I cannot change the template!

    John Rostron

  • #2
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It didn't worked for me.
    I don't use external .js file for "clientSideInclude". I simply out row in the file inside <script> tag.

    Then I used the function

    <script>
    function Doit()
    {
    clientSideInclude('header', '/ssi/header.asp');
    clientsideInclude('footer', '/ssi/footer.asp');
    }
    </script>

    to insert more than one includes.

    I put the function here

    <body onLoad= "Doit();">

    ..and the appropriate <div> in my file to get the includes but i get the first one ALWAYS!

    Any ideas?

    Thanks in advance.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    you second one is mispelled.
    javascript os case-sensitive

    clientsideInclude should be clientSideInclude
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •