Jump to content

Only Works Once In Firefox?


Recommended Posts

This is a strange one to me. I wrote a captcha script for my site which works fine. On the sign up page I put it on I have a JavaScript function that uses ajax to refresh the captcha without reloading the page. That works in all my browsers but Firefox and Opera. In these browsers you can click it once and it works, after that it doesn't refresh the image. When add an alert at the end of the function it shows that the function is firing, so it's acting like the page is caching, even though I'm sending it with POST. Does any one know why these two browsers are doing that and how to stop it? The code is:

function loadXMLDoc(div){if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200){	  document.getElementById(div).innerHTML=xmlhttp.responseText;}}}function refreshcaptcha (){loadXMLDoc("captcha")    xmlhttp.open("POST","refreshcaptcha.php",true);xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');xmlhttp.send();}

  • Like 1
Link to post
Share on other sites

I've already tried that one, thanks though. It was my understanding that POST doesn't catch in AJAX, though I may have miss understood that. It acts like it's catching, but only in 2 out of 5 browsers. Any other ideas? Notes: I've entered in all the no catch headers i could find on the PHP page that the request is sent to, and tried all the common stuff you can find on Google.

Link to post
Share on other sites

It's not whether the method is get or post, it's really whether you add a query string to the URL.Did you see this part of the code I presented?"refreshcaptcha.php?r=" + Math.random()

Link to post
Share on other sites

The other possibility is that your PHP script is always returning the same data. If you have Firebug you can see if the response is loaded from cache or not.

Link to post
Share on other sites

Now I'm even more confused. First off i realized the Ajax was unnecessary, So I switched to DHTML to do the same job. Now when i try to use the script 1 of 2 things happen: If I don't load fire bug with the script it does the same thing as before, doesn't refresh the image. If I do load fire bug then it ether does the same thing as before, or, most often, it works, but the resulting image from fire bug is different than on the webpage, and the firebug code works but not the site code. I don't have the first clue wtf is going on now. It's like firebug sends it's own request to the captcha page and resets it for the main page, but if fire bug doesn't do that then the main page catches the data.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...