View Full Version : smoothmenu - refresh when external file changes

04-15-2012, 12:54 AM
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

04-15-2012, 08:40 AM
Using a text only editor like NotePad, open up the ddsmoothmenu.js file. Find the below code around line#32 and add the highlighted:

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...")
url: setting.contentsource[1], //path to external menu file
cache: false,
async: true,
$menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText)
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.

04-18-2012, 12:35 PM
Thanks so much! That seems to have done the trick.