Javascript 由于错误 80020101,无法完成操作。IE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10903989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:30:18  来源:igfitidea点击:

Could not complete the operation due to error 80020101. IE

javascriptinternet-explorer

提问by Asif Alamgir

Possible Duplicate:
Ajax request problem: error 80020101

可能重复:
Ajax 请求问题:错误 80020101

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

我正在使用 JQuery-1.64,这是我重置计时器的代码

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????

但它给了我一个错误,仅在 IE 中,当我尝试执行 clearTimeout 时。任何的想法????

回答by Asif Alamgir

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.

没有意义,但它对我有用。

回答by Eric J.

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.

所有错误 80020101 意味着在评估 JavaScript 时出现某种错误。如果您通过 Ajax 加载该 JavaScript,则评估过程特别严格。

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

查看您的 Ajax 调用返回的确切 JavaScript,并查找该脚本中的任何问题。有关更多详细信息,请参阅此处的精彩文章

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

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

回答by Chris Brickhouse

wrap your entire code block in this:

将您的整个代码块包装在:

//<![CDATA[

//code here

//]]>

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

还要确保将脚本类型指定为 text/javascript

try that and let me know how it goes

试试看,让我知道它是怎么回事

回答by Slava

Switch off compatibility view if you use IE9.

如果您使用 IE9,请关闭兼容性视图。

回答by Crayon Violent

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

你什么时候调用 timerReset()?也许你在 setTimeout() 已经完成它的事情之后尝试调用它时会遇到那个错误?

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:

编辑:实际上,经过进一步思考,因为您确实提到了 jQuery(但这里没有任何实际的 jQuery 代码...我想知道您是否将它嵌套在某个 jQuery 中(例如在 a 中$(document).ready(..,这是变量范围的问题) . 如果是这样,试试这个:

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);
}