I've seen this caching problem before as well. I handle it by just adding a random number to the URL I'm requesting.

i.e.

$.ajax({
  url: "mypage.cfm?r=" + Math.random(),
  data: myData,
  //. . .
});

If you are doing a GET request, the random parameter can go into the Data then. The parameter name is arbitrary and is just ignored on the server side.

This essentially forces IE to request a NEW page each time. It has the bonus that you don't need any special CF magic (such as adjusting headers). But I'd imagine setting the headers is probably better in the long run.

HTH

Shawn

Carl Von Stetten wrote:
Rick,

I've had problems in the past with IE using the cached version of AJAX
content instead of reloading it.  The solution that generally works is
to add this to the top of the .cfm page your are loading via AJAX:

<cfheader name="expires" value="#now()#">
<cfheader name="pragma" value="no-cache">
<cfheader name="cache-control" value="no-cache, no-store, must-
revalidate">
<Your CF code here...

See if that helps.
Carl

On Jan 8, 5:08 pm, "Rick Faircloth" <r...@whitestonemedia.com> wrote:
Hi, Carl...and thanks for the reply.

Yes, the conditional statements are in the include_menu_index.cfm file.

They determine the menu like so:

                <cfif isdefined("session.announcements") and session.announcements 
eq 1>
                        <li><a 
href="cfm/announcements.cfm">Announcements</a></li>
                </cfif>

                <cfif isdefined("session.res_announcements") and 
session.res_announcements eq 1>
                        <li><a href="cfm/res_announcements.cfm">RES 
Announcements</a></li>
                </cfif>

etc....

FF3 does re-process the CF.  IE doesn't.  I confirmed that by putting this code
at the top of the include_menu_index.cfm file:

<cfset greeting = "Hi, Rick" />
<cfoutput>greeting = #greeting#</cfoutput>

Next, I logged out, clearing the session variables, then logged back in
and got "greeting = Hi, Rick" at the top of the menu.

Then, before logging in as another user with different access to menu items, and
therefore a different menu structure, I changed "Rick" to "Bob" and saved the
include_menu_index.cfm file.

I logged in as the new user, and sure enough, I got "greeting = Hi, Rick" 
instead
of what was actually in the template, "greeting = Hi, Bob".

Only when I refreshed the page did I get the correct greeting, "greeting = Hi, 
Bob".

I've tried everything to try and figure out a way to get IE to re-render the 
menu,
but everything I've tried has failed.

I think I may have to use the cfc that processes the user's credentials to 
create
the appropriate menu and save that content as plain HTML, then load that with 
jQuery.
The loading seems to work with plain HTML, but without re-freshing, processing 
of
code doesn't run.

Thoughts?

Rick

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf 
Of Carl Von Stetten
Sent: Thursday, January 08, 2009 5:13 PM
To: jQuery (English)
Subject: [jQuery] Re: How to force processing of ColdFusion code when using 
.load
Rick,
Is the ColdFusion conditional code in the includes/
include_menu_index.cfm file?
If so, there may be issues with the AJAX request not using the same
ColdFusion session as your main page.
Also, you might check your AJAX response using Fiddler with IE and
compare it to the response in Firefox using Firebug.
HTH,
Carl
On Jan 8, 3:04 pm, "Rick Faircloth" <r...@whitestonemedia.com> wrote:
How can I force the processing of ColdFusion code in a menu
segment when I have some login and I replace the menu HTML.
I had some conditional code like:
                <cfif isdefined("session.announcements") and session.announcements 
eq 1>
                        <li><a 
href="cfm/announcements.cfm">Announcements</a></li>
                </cfif>
                <cfif isdefined("session.res_announcements") and 
session.res_announcements eq 1>
                        <li><a href="cfm/res_announcements.cfm">RES 
Announcements</a></li>
                </cfif>
This code displays menu items only if the user has clearance
to access those sections in a site manager.
The problem I have is the IE (seems to be working fine in FF3)
is not processing the CF code unless I do a full page refresh...then it
displays the menu appropriately.
Here's the jQuery...any idea how to force IE to reprocess the CF, too?
$.ajax({
     type: "POST",
     url:  "login/login_processor.cfm",
     dataType: "json",
     data: formval,
     success: function(response){
           if (response.login == "Login Successful")
              { $('#logstatus').empty().append("Log Out");
                $('#menu').hide();
                $('#menu').load("includes/include_menu_index.cfm").show();
           tb_remove() }

Reply via email to