Results 1 to 3 of 3

Thread: smoothmenu - refresh when external file changes

  1. #1
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default smoothmenu - refresh when external file changes

    1) Script Title: Smooth Navigational Menu (v1.5)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...smoothmenu.htm

    3) Describe problem: Putting the Menu contents in an external file and fetched using Ajax

    I have my menu contents in an external file and it works fine except for when I make a change to the menu. I have clear my cache or bring up the menu html directly and reload it to see the changes. This is fine for me to do, but not so good for the folks using my website. Is there a way to get the menu to refresh when it's changed or get it to load from the server and not the cache? I tried putting a meta tag on my home page so that it would not load from the cache, but the menu changes still don't show up. Any ideas would be appreciated! Thanks

    my site is www.rfhcrew.com

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,167
    Thanks
    44
    Thanked 3,240 Times in 3,201 Posts
    Blog Entries
    12

    Default

    Using a text only editor like NotePad, open up the ddsmoothmenu.js file. Find the below code around line#32 and add the highlighted:

    Code:
    getajaxmenu:function($, setting){ //function to fetch external page containing the panel DIVs
    	var $menucontainer=$('#'+setting.contentsource[0]) //reference empty div on page that will hold menu
    	$menucontainer.html("Loading Menu...")
    	$.ajax({
    		url: setting.contentsource[1], //path to external menu file
    		cache: false,
    		async: true,
    		error:function(ajaxrequest){
    			$menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText)
    		},
    		success:function(content){
    			$menucontainer.html(content)
    			ddsmoothmenu.buildmenu($, setting)
    		}
    	})
    },
    Ironically you may have to refresh the page and/clear the browser's cache to see changes. But once you have, it will no longer cache the external file. Your users, as long as they haven't visited the page recently will not need to do this. Even if they have, it won't be long before their browser does this for them automatically.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    nmp56 (04-18-2012)

  4. #3
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks so much! That seems to have done the trick.

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
  •