I am having trouble with the following; onClick="updateMysql()" calls getNextTelephone() onSuccess, this returns the next telephone from a list and sets the global variable globalTelephone with the new telephone number. The next onClick will use displayNextTelephone() to change the telephone number with the new one getNextTelephone() set the globalTelephone to previously. When you click the button it gets and displays the next telephone from the list. This works fine in Firefox but IE6 displays the first telephone number and then nothing. When I reload the page with SHIFT it still displays the first number. When I restart IE6 it gets the next number but that is it. Any help would be appreciated. Thanks Ken <html> <head> <title>Example</title> <script language="Javascript" src="includes/scripts/prototype/ prototype.js"></script> <script language="javascript" type="text/javascript"> var globalTelephone = ''''; function updateMysql() { displayNextTelephone(); var url = "update_mysql.php"; new Ajax.Request(url, { asynchronous: true, method: "get", onSuccess: function(request) { getNextTelephone(); }, onFailure: function(request) { alert(''error''); } }); } function displayNextTelephone(){ $(''telephone'').value = globalTelephone; } function getNextTelephone(){ var url = "get_next_telephone.php"; new Ajax.Request(url, { asynchronous: true, method: "get", onSuccess: function(request) { results = request.responseText; }, onFailure: function(request) { alert(''error''); } }); globalTelephone = results; } </script> </head> <body> <form action="post"; <p> Telephone: <input type="text" size="10" id="telephone" /> </p> <button type="button" name="button" onClick="updateMysql()"> Get Next Telephone </button> </form> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
sounds like the ajax caching bug, where the browser will use the cache to grab data from if the url doesn''t change. in my experience FF doesn''t usually have this problem is used this function function cBuster(){ var cBuster=parseInt(Math.random()*99999999); // cache buster return cBuster; } and in the ajax.updater i added var params = ''action=getsomething&id='' + document.Frm.user_list[document.Frm.user_list.selectedIndex].value + ''&cb=''+cb; basically it appends a random 8 digit number to the URL so that the browser always thinks its a new visit. Another way you could do it is via the headers of the returned page pragma:no-cache and there are a couple of other ways but the above seemed to be the simplest. HTH On Nov 20, 2007 11:27 PM, kenq <nniuqnek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am having trouble with the following; > onClick="updateMysql()" calls getNextTelephone() onSuccess, this > returns the next telephone from a list and sets the global variable > globalTelephone with the new telephone number. The next onClick will > use displayNextTelephone() to change the telephone number with the > new one getNextTelephone() set the globalTelephone to previously. When > you click the button it gets and displays the next telephone from the > list. This works fine in Firefox but IE6 displays the first telephone > number and then nothing. When I reload the page with SHIFT it still > displays the first number. When I restart IE6 it gets the next number > but that is it. > Any help would be appreciated. > Thanks > Ken > > <html> > <head> > <title>Example</title> > <script language="Javascript" src="includes/scripts/prototype/ > prototype.js"></script> > <script language="javascript" type="text/javascript"> > > var globalTelephone = ''''; > > function updateMysql() { > displayNextTelephone(); > var url = "update_mysql.php"; > new Ajax.Request(url, { > asynchronous: true, > method: "get", > onSuccess: function(request) { > getNextTelephone(); > }, > onFailure: function(request) { > alert(''error''); > } > }); > } > > function displayNextTelephone(){ > $(''telephone'').value = globalTelephone; > } > > function getNextTelephone(){ > var url = "get_next_telephone.php"; > new Ajax.Request(url, { > asynchronous: true, > method: "get", > onSuccess: function(request) { > results = request.responseText; > }, > onFailure: function(request) { > alert(''error''); > } > }); > globalTelephone = results; > } > > </script> > </head> > <body> > <form action="post"; > <p> > Telephone: <input type="text" size="10" id="telephone" /> > </p> > <button type="button" name="button" onClick="updateMysql()"> Get Next > Telephone > </button> > </form> > </body> > </html> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
If you do it like this (which isn''t necessary with proper HTTP headers), you can use: ''&cb='' + (new Date()).getTime() instead. This guarantees a unique number everytime (except if you have more than a thousand requests per second from the same client; but that wouldn''t work anyway). Best, Thomas Am 21.11.2007 um 17:14 schrieb Brian Williams:> sounds like the ajax caching bug, where the browser will use the > cache to grab data from if the url doesn''t change. > > in my experience FF doesn''t usually have this problem > > is used this function > > function cBuster(){ > var cBuster=parseInt(Math.random()*99999999); // cache buster > return cBuster; > } > > and in the ajax.updater i added > > var params = ''action=getsomething&id='' + > document.Frm.user_list[document.Frm.user_list.selectedIndex].value + > ''&cb=''+cb; > > basically it appends a random 8 digit number to the URL so that the > browser always thinks its a new visit. Another way you could do it > is via the headers of the returned page pragma:no-cache and there > are a couple of other ways but the above seemed to be the simplest. > > HTH > > On Nov 20, 2007 11:27 PM, kenq <nniuqnek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am having trouble with the following; > onClick="updateMysql()" calls getNextTelephone() onSuccess, this > returns the next telephone from a list and sets the global variable > globalTelephone with the new telephone number. The next onClick will > use displayNextTelephone() to change the telephone number with the > new one getNextTelephone() set the globalTelephone to previously. When > you click the button it gets and displays the next telephone from the > list. This works fine in Firefox but IE6 displays the first telephone > number and then nothing. When I reload the page with SHIFT it still > displays the first number. When I restart IE6 it gets the next number > but that is it. > Any help would be appreciated. > Thanks > Ken > > <html> > <head> > <title>Example</title> > <script language="Javascript" src="includes/scripts/prototype/ > prototype.js "></script> > <script language="javascript" type="text/javascript"> > > var globalTelephone = ''''; > > function updateMysql() { > displayNextTelephone(); > var url = "update_mysql.php"; > new Ajax.Request(url, { > asynchronous: true, > method: "get", > onSuccess: function(request) { > getNextTelephone(); > }, > onFailure: function(request) { > alert(''error''); > } > }); > } > > function displayNextTelephone(){ > $(''telephone'').value = globalTelephone; > } > > function getNextTelephone(){ > var url = "get_next_telephone.php"; > new Ajax.Request(url, { > asynchronous: true, > method: "get", > onSuccess: function(request) { > results = request.responseText ; > }, > onFailure: function(request) { > alert(''error''); > } > }); > globalTelephone = results; > } > > </script> > </head> > <body> > <form action="post"; > <p> > Telephone: <input type="text" size="10" id="telephone" /> > </p> > <button type="button" name="button" onClick="updateMysql()"> Get Next > Telephone > </button> > </form> > </body> > </html> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the replies, adding the random number to the url works. I could not get it to work with pragma:no-cache in the header. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I read somewhere that Pragma: no-cache is not well supported. I use this triplet, which seems to solve all my problems Pragma: no-cache Cache-Control: no-cache, must-revalidate Expires: Fri, 01 Jan 1990 00:00:00 GMT It''s also Google''s choice of techniques, so it must work well, right? Mind the capital letters, would you? I personally like meaningful urls better; slapping a random number to the URL is a bit too harsh for my taste. On Nov 21, 11:10 pm, kenq <nniuq...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the replies, adding the random number to the url works. I > could not get it to work with pragma:no-cache > in the header. > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---