Results 1 to 2 of 2

Thread: Ajax Rotating Includes - Can I call the code from an external page?

  1. #1
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Ajax Rotating Includes - Can I call the code from an external page?

    1) Script Title: Ajax Rotating Includes

    2) Script URL: http://www.dynamicdrive.com/dynamici...ajaxrotate.htm

    I'd like to be able to call the javascript from an external page, thus avoiding the lengthy code at the top of the page. I really know nothing about javascript, although I have done this successfully in the past...

    Here's what I tried:
    HTML Code:
    <script type="text/javascript" src="resources/rotating_content.js">
    ajaxinclude(includefiles, "random")
    </script>
    My pages is here:
    http://www.sweetsomethingschocolate.com/testing/

    Thanks for any help you can give me--I feel like this should be a relatively simple answer, but I could definitely be wrong.

  2. #2
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    Hi,

    I would suggest to use the jQuery framework in order to accomplish this.
    I use it myself and it's proven both effective and compatible.

    Simply download jQuery (I'd suggest the minified version) from http://jquery.com.
    Then, on your website, just put this snippet of code:
    Code:
    <script type="text/javascript" src="jquery_1_2_6.js"></script>
    ... replace 'jquery_1_2_6.js' by whatever name you call your jQuery file.

    I'd suggest putting this code at the end of page, i.e.:
    Code:
    <script type="text/javascript" src="jquery_1_2_6.js"></script>
    </body>

    Then, you can call your external JavaScript file like this:
    Code:
    $.getScript('external.js', function(data) {
      alert('This message is shown when the file has been successfully loaded.');
    });

    Hope this helps.
    Cyber

Bookmarks

Posting Permissions

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