views:

94

answers:

2

I'm using the jQuery jEditable plug-in to edit some part of a website.

As the text use Textile format, I use the LoadURL option to bring in the unformatted data.

The problem arise when the user edits some text, and then go back to re-edit it, the ajax call brings back the cached result.

I've tried to add a random parameter, but the same random number is added, so it is useless.

        $(".edit").livequery(function(){$(this).editable("<%=Page.ResolveUrl("~/savetext.aspx") %>", {
             loadurl   : '<%=Page.ResolveUrl("~/gettext.aspx") %>?Rnd=' + Math.random().toString(),
             type      : 'textarea',
             cancel    : 'Cancel',
             submit    : 'Save',
             indicator : 'Saving...',
             rows      : 4,
             tooltip   : 'click to edit'
            });
        });

Is there a way to tell jEditable to add a random parameter in each call?

A: 

Can we have a look on gettext.aspx.... Maybe we can come up a solution if you do....

Reigel
I don't see the point, As I said, it works perfectly, the only trouble is that sometimes it is cached by some browsers.
Eduardo Molteni
+1  A: 

I'm seeing this too, but only intermittently. I realised that in my equivalent to gettext.aspx (which in my case is PHP code), I was not setting response headers to prevent browser caching. I have added something like this and it seems to be behaving better:

header("Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );

I'm no asp developer, but after searching around I think an equivalent might be:

HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Current.Response.Cache.SetValidUntilExpires(false); 
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore(); 
rewbs
Good one, I will try.
Eduardo Molteni