Dido123
asked on
Ajax problem with IE ... IE doesn't update/refresh
Hi,
I have Ajax script that shows image after every test completion. It works and update just fine in all browsers except IE. IE only shows the first test and it doesn't update after that. I think it's a cache problem. I also confirmed that by searching on Google.
This is my current code. What should I do to bypass this IE problem?
I have Ajax script that shows image after every test completion. It works and update just fine in all browsers except IE. IE only shows the first test and it doesn't update after that. I think it's a cache problem. I also confirmed that by searching on Google.
This is my current code. What should I do to bypass this IE problem?
function getTestID() {
var xmlhttp = null;
if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
if(xmlhttp != null) {
xmlhttp.open("GET","getid.php",false);
xmlhttp.send();
return xmlhttp.responseText;
}
return -1;
}
function test_completed(result1, results2) {
var myid = getTestID();
if(myid!=-1) {
document.getElementById("mypic").innerHTML = "<img src='http://www.mywebsite.com/result/" + myid + ".png'><br>" + "Direct Link:<br><input type='text' readonly='readonly' size='37' value='http://www.mywebsite.com/result/" + myid + ".png'<br>" + "Forum Link:<br><input type='text' readonly='readonly' size='37' value='[URL=http://www.mywebsite.com][IMG]http://www.mywebsite.com/result/" + myid + ".png[/IMG][/URL]'<br>";
ASKER
Is there any better solution? I found this one when I was searching on Google but I'm thinking that there might be a better one.
I'm not sure? Better how?
You could also use javascript: document.location = "yourpage.php".
Personally, I like meta refresh better as javascript can be turned off. I've used it on several sites. It even passes XHTML validation. What's your concern with using it?
-Ray
You could also use javascript: document.location = "yourpage.php".
Personally, I like meta refresh better as javascript can be turned off. I've used it on several sites. It even passes XHTML validation. What's your concern with using it?
-Ray
Hello Dido123,
Replace your test_completed function by this one :
Replace your test_completed function by this one :
function test_completed(result1, results2) {
var myid = getTestID();
if(myid!=-1) {
var url = "http://www.mywebsite.com/result/" + myid + ".png";
var img = document.createElement("img");
img.src = url;
var br1 = document.createElement("br");
var tn1 = document.createTextNode("Direct Link:");
var br2 = document.createElement("br");
var input1 = document.createElement("input");
input1.type = "text";
input1.setAttribute("readonly","readonly");
input1.setAttribute("size","37");
input1.value = url;
var br3 = document.createElement("br");
var tn2 = document.createTextNode("Forum Link:");
var br4 = document.createElement("br");
var input2 = document.createElement("input");
input2.type = "text";
input2.setAttribute("readonly","readonly");
input2.setAttribute("size","37");
input2.value = "[URL=http://www.mywebsite.com][IMG]" + url + "[/IMG][/URL]";
var br5 = document.createElement("br");
var mypic = document.getElementById("mypic")
mypic.appendChild(img);
mypic.appendChild(br1);
mypic.appendChild(tn1);
mypic.appendChild(br2);
mypic.appendChild(input1);
mypic.appendChild(br3);
mypic.appendChild(tn2);
mypic.appendChild(br4);
mypic.appendChild(input2);
mypic.appendChild(br5);
}
}
ASKER
leakim971, awesome as usual! :)
One more request ...
How I add this line code to the new code? I used it in the old functions.js to report to Google Analytics that test completed ....
Thank you so much for your great support.
One more request ...
How I add this line code to the new code? I used it in the old functions.js to report to Google Analytics that test completed ....
Thank you so much for your great support.
+ pageTracker._trackPageview('/done/');
what's your previous integration ?
ASKER
At the end of the old function :
function test_completed(result1, results2) {
var myid = getTestID();
if(myid!=-1) {
document.getElementById("mypic").innerHTML = "<img src='http://www.mywebsite.com/result/" + myid + ".png'><br>" + "Direct Link:<br><input type='text' readonly='readonly' size='37' value='http://www.mywebsite.com/result/" + myid + ".png'<br>" + "Forum Link:<br><input type='text' readonly='readonly' size='37' value='[URL=http://www.mywebsite.com][IMG]http://www.mywebsite.com/result/" + myid + ".png[/IMG][/URL]'<br>"; + pageTracker._trackPageview('/done/');
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tested it out first in Firefox and I got two problems:
1. It gives me "undefined" below Forum Link .. I'm sure it's from the Google Analytics line isn't executing correctly.
2. When I do "restart test" the new results show below the current one. It doesn't replace it.
1. It gives me "undefined" below Forum Link .. I'm sure it's from the Google Analytics line isn't executing correctly.
2. When I do "restart test" the new results show below the current one. It doesn't replace it.
ASKER
I also tried it in IE and I noticed that the duplicated results are all the same, which means that IE problem still not solved.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Great!
ASKER
@leakim971 .. thanks
here is a new related question for you : https://www.experts-exchange.com/questions/25833686/Hyperlink-in-Javascript.html
here is a new related question for you : https://www.experts-exchange.com/questions/25833686/Hyperlink-in-Javascript.html
[code]<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">[/code]
HTH,
-Ray