36

Possible Duplicate:
Ajax request problem: error 80020101

I am using JQuery-1.64 and this is my code to reset timer

var message="Logged in";
var myTimeout = setTimeout("timerDone()",1000 * 1440);
function timerDone()
{
    message="Logged out";   
}
function timerReset()
{


    clearTimeout(myTimeout);
    myTimeout = setTimeout("timerDone()", 1000 * 1440);
}

But it gives me an error, only in IE, when I am trying to do clearTimeout. Any Idea????

Community
  • 1
  • 1
Asif Alamgir
  • 1,454
  • 1
  • 16
  • 41

5 Answers5

38

I dont know why but it worked for me. If you have comments like

//Comment

Then it gives this error. To fix this do

/*Comment*/

Doesn't make sense but it worked for me.

Otto Allmendinger
  • 27,448
  • 7
  • 68
  • 79
Asif Alamgir
  • 1,454
  • 1
  • 16
  • 41
34

All the error 80020101 means is that there was an error, of some sort, while evaluating JavaScript. If you load that JavaScript via Ajax, the evaluation process is particularly strict.

Sometimes removing // will fix the issue, but the inverse is not true... the issue is not always caused by //.

Look at the exact JavaScript being returned by your Ajax call and look for any issues in that script. For more details see a great writeup here

http://mattwhite.me/blog/2010/4/21/tracking-down-error-80020101-in-internet-exploder.html

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • followed this and it worked :) – Bogdan Sep 20 '12 at 20:39
  • 1
    An example: If you load a partial HTML document and add it to your document (for instance using AngularJS) that has a script tag it might help including the JavaScripts directly – Joelbitar Sep 06 '13 at 06:48
5

wrap your entire code block in this:

//<![CDATA[

//code here

//]]>

also make sure to specify the type of script to be text/javascript

try that and let me know how it goes

Chris Brickhouse
  • 650
  • 5
  • 15
2

Switch off compatibility view if you use IE9.

Slava
  • 3,445
  • 1
  • 20
  • 16
0

when do you call timerReset()? Perhaps you get that error when trying to call it after setTimeout() has already done its thing?

wrap it in

if (window.myTimeout) { 
  clearTimeout(myTimeout);
  myTimeout = setTimeout("timerDone()", 1000 * 1440);
}

edit: Actually, upon further reflection, since you did mention jQuery (and yet don't have any actual jQuery code here... I wonder if you have this nested within some jQuery (like inside a $(document).ready(.. and this is a matter of variable scope. If so, try this:

window.message="Logged in";
window.myTimeout = setTimeout("timerDone()",1000 * 1440);
function timerDone()
{
    window.message="Logged out";   
}
function timerReset()
{


    clearTimeout(window.myTimeout);
    window.myTimeout = setTimeout("timerDone()", 1000 * 1440);
}
CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
  • 1
    timerReset() is called whenever user clicks on something or basically whenever page loads. – Asif Alamgir Jun 06 '12 at 14:24
  • It did not work. I am not sure if it is this error, even though IE is pointing to it, because when it loads it should show accordion tabs, which it doesn't in IE. Also, IE is pointing to jQuery1.6 error for some reason – Asif Alamgir Jun 06 '12 at 14:32