Ajax请求问题:错误80020101

发布于 2024-10-16 02:36:27 字数 115 浏览 3 评论 0原文

我有一个返回 jsp 页面的请求。但事实是,jsp 中包含 jsp:include (它调用其中的另一个 jsp 文件),并且 ie 给出错误 80020101。

有什么想法吗?

谢谢

I have a request which returns a jsp page. But the fact is, the jsp includes jsp:include in it(it calls another jsp file in it) and ie gives the error 80020101.

Any ideas?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

迷离° 2024-10-23 02:36:27

如果您从 jQuery 进行 AJAX 调用并且在数组末尾传递了一个额外的逗号,您也可能会收到此错误,如下所示:

$.post('http://example.com/example1/',{
  field1:sField1,
  field2:sField2,
  field3:sField3,
  field4:sField4,
  field5:sField5,
},function(sData){
  if (console) { console.log(sData); }
});

看到 sField5 之后的逗号了吗?这就是语法错误。除了 IE 之外,没有其他浏览器会关心。 IE 将抛出晦涩难懂的 80020101 错误(这意味着“无法评估你的 Javascript——你有一个语法错误”),如果你使用 jQuery,那么追踪它实际上会令人困惑,因为调试器只会指向 eval 行在 jQuery 中。感谢微软,IE 调试器对你来说是没有用的。下次您收到 80020101 错误时,我的建议是:

  1. 查找任何 AJAX 调用并查找多余的逗号。
  2. 查找末尾有多余逗号的任何数组(例如大括号中的内容)。
  3. 如果这仍然没有帮助,那么请查看使用 来标记 Javascript 的技术。在 1.7.2 之前,这一直是 jQuery 的一个已知问题,并且仍然是 jQuery 团队提交的错误。
  4. 迁移到最新版本的 jQuery。
  5. 开始从脚本块中一点一点地删除内容,然后慢慢添加这些内容,直到找到有问题的代码段。

You can also get this error if you're doing an AJAX call from jQuery and you pass an extra comma on the end of the array, like so:

$.post('http://example.com/example1/',{
  field1:sField1,
  field2:sField2,
  field3:sField3,
  field4:sField4,
  field5:sField5,
},function(sData){
  if (console) { console.log(sData); }
});

See that comma after the sField5? That's the syntax error. No other browser will care but IE. IE will throw the obscure 80020101 error (which means "cannot evaluate your Javascript -- you have a syntax error") and it will be practically baffling to chase it down if you're using jQuery because the debugger will merely point to the eval line in jQuery. The IE debugger will be of no use to you to chase this, thanks to Microsoft. The next time you get the 80020101 error, my suggestions are:

  1. Look for any AJAX calls and look for an extra comma.
  2. Look for any arrays (like stuff in curly braces) where there's an extra comma at the end.
  3. If that still doesn't help, then look at the technique where you use <!-- and //--> to mark off your Javascript. This has been a known problem with jQuery up until 1.7.2 and it's still a filed bug with the jQuery team.
  4. Move to the latest version of jQuery.
  5. Start removing stuff piece by piece out of your script block and adding the items in slowly until you find the offending piece of code.
驱逐舰岛风号 2024-10-23 02:36:27

删除使用 src-attribute 导入脚本的 javascript 声明。如果您确实需要的话,请将您的 javascript 文件更改为 inline-javascript 。

来源: http: //bytes.com/topic/javascript/answers/750333-ie-syntax-error-80020101-undefined-array

最简单的方法是向 AJAX 请求添加参数,例如 ajax= 1 并在请求中存在 ajax 参数时隐藏 javascript 声明。

我认为这与使用 jsp:include 包含文件没有任何关系,因为浏览器除了您抛出的 HTML 之外不知道其他任何东西。

Remove javascript declarations that imports a script using src-attribute. Change your javascript-file to inline-javascript if you really need it there.

Source: http://bytes.com/topic/javascript/answers/750333-ie-syntax-error-80020101-undefined-array

Easiest way to would be to to add a parameter to your AJAX request such as ajax=1 and hide the javascript declarations when ajax -parameter exists is in request.

I don't think this has anything to do with including files with jsp:include since the browser does not know aynthing else than the HTML you throw it with.

笑,眼淚并存 2024-10-23 02:36:27

我现在已经在 jQuery(甚至是最新版本)中遇到过这个问题两次。唯一的解决方案是将所有 JavaScript 复制并粘贴到一个大文件中,然后通过 JSLint(jsfiddle.net,首选)运行它。它能够指出几个小错误(包括我的数据回调结构之一中的额外逗号),我能够修复这些错误,然后重新复制并粘贴回原来的位置以消除问题。

http://jsfiddle.net/devlshone/QKxup/3/

I have now come across this problem with jQuery (even the latest version) twice. The ONLY solution is to copy and paste all of your javascript into one big file and run it through JSLint (jsfiddle.net, preferred). It was able to point out several minor errors (including an extra comma in one of my data callback structures) that I was able to fix and then re-copy and paste back into their original places to eliminate the issue.

http://jsfiddle.net/devlshone/QKxup/3/

萌无敌 2024-10-23 02:36:27

我遇到了同样的错误,但就我而言,有一个保留字'class'
下面是一段代码,可以清楚地说明这一点:

function foo(ajaxResponse){
  $(elem).attr('class', ajaxResponse.class);
}

我将其重写为:

$(elem).attr('class', ajaxResponse['class']);

希望这有帮助。

I had the same error, but in my case there was a reserved word 'class'.
Here is a snippet of code to make this clear:

function foo(ajaxResponse){
  $(elem).attr('class', ajaxResponse.class);
}

I rewrote this as:

$(elem).attr('class', ajaxResponse['class']);

Hope this was helpful.

亽野灬性zι浪 2024-10-23 02:36:27

就我而言,我发现我的 JS 代码中有一个 HTML 注释:

<script type="text/javascript">
<!-- Unexpected Comment -->
//code...
</script>

我将 替换为 /* */ 并且它有效。
希望它能帮助某人。

In my case I found that there was an HTML comment in my JS code as:

<script type="text/javascript">
<!-- Unexpected Comment -->
//code...
</script>

I replaced <!-- --> with /* */ and it worked.
Hope it will help someone.

情痴 2024-10-23 02:36:27

我遇到了这个问题,IE 的错误消息没有太大帮助。因此,我在 Mozilla Firefox 中访问了我的网站,Firefox 能够准确定位有问题的代码行。这不是高科技修复,但如果您仅使用 IE 来调试此问题,请尝试在 FF 中加载您的站点(安装了 Firebug 扩展)并检查控制台输出。

I ran into this issue and IE's error messages weren't very helpful. So, I visited my site in Mozilla Firefox and Firefox was able to pinpoint the exact line of code that was problematic. Not a high tech fix but if you have been using just IE for debugging this issue, try loading your site in FF (with the Firebug extension installed) and checking the console output.

孤寂小茶 2024-10-23 02:36:27

我也遇到了这个问题,但是仔细查看我的脚本文件后,我发现我犯了一个小错误,在其他浏览器上运行顺利,但 IE 选择它并向我显示错误:

我以前的代码是:

var autocomplete = new google.maps.places.Autocomplete(searchTextField ,options);

分析后,我知道 searchTextField 是 id,我必须在使用它之前获取它的值

,所以我将其更改为:

var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input,options);

并且它工作正常。

IE 检测到它确实很酷,但微软可能会增强浏览器以显示特定原因的特定错误,因为如果相同的代码在其他浏览器中运行,那将非常令人沮丧

I also ran into this issue, but after taking a close look at my script file, I found out that I made a small mistake that run smoothly on other browser but IE pick it and show me the error:

My previous code was:

var autocomplete = new google.maps.places.Autocomplete(searchTextField ,options);

After analyzing, I got that searchTextField is id and I have to get its value before using it

So I change it to:

var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input,options);

and it works fine.

That's really cool that IE detects it, but Microsoft may enhance the browser to show specific error for specific cause, because it's very frustrating if same code works in other browsers

雨后咖啡店 2024-10-23 02:36:27

就我而言,问题是错误函数末尾的 Ajax POST 中额外无用的昏迷:

$.ajax({
     type: 'POST',
     dataType: 'text',
     url: '../Client/GetName',
     data: { ClientId: id},
     success: function (respone) {
                alert(respone);
     },
     error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.statusText);
     }, //<- look here, this guy complicated my simple programmer life
 });

将其删除后,一切正常。

In my case the problem was additional useless coma in Ajax POST in the end of error function:

$.ajax({
     type: 'POST',
     dataType: 'text',
     url: '../Client/GetName',
     data: { ClientId: id},
     success: function (respone) {
                alert(respone);
     },
     error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.statusText);
     }, //<- look here, this guy complicated my simple programmer life
 });

After removed it everything works fine.

国产ˉ祖宗 2024-10-23 02:36:27

你有机会包含一个js文件吗?

因为

错误 80020101 意味着 IE 无法编译您的脚本。

Are you by any chance including a js file ?

Because

Error 80020101 means that IE isnt't able to compile your script.

最美的太阳 2024-10-23 02:36:27

使用 jquery 时因不同问题而出现此错误。

改变
$(document).ready(function(){});

$(window).load(function(){});

Got this error for a different issue while using jquery.

Change
$(document).ready(function(){});
TO
$(window).load(function(){});

三五鸿雁 2024-10-23 02:36:27

想分享我的经验。就我而言,它与 javascript 无关。这是因为同事的 HTML 中使用 Angular 的这一行:

 <img data-ng-model="previewImage" src="" data-ng-src="{{imageURL}}" alt="" ></img>

我记得有一个空的 src 通常是一件坏事。我填充了 src 字段,错误就消失了。

Wanted to share my experience. In my case it had nothing to do with javascript. It was because of this line in a coworker's HTML that uses angular:

 <img data-ng-model="previewImage" src="" data-ng-src="{{imageURL}}" alt="" ></img>

I remembered that having an empty src is usually a bad thing. I populated the src field and the error went away.

×眷恋的温暖 2024-10-23 02:36:27

我在使用 jQuery 1.10.2 并加载不存在的文件时遇到了此错误。

因此请确保您尝试加载的文件是正确的,否则 IE8 会抛出 80020101 错误。

I experienced this error when using jQuery 1.10.2 and was loading a file that didn't exist.

So make sure the file you try to load is correct, otherwise IE8 can throw the 80020101 error.

风轻花落早 2024-10-23 02:36:27

我的问题是由以下原因引起的:

var a = b = c = true;

转向

var a = true;
var b = true;
var c = true;

现在它工作正常!

再见
硕士

My issues were caused by:

var a = b = c = true;

turned to

var a = true;
var b = true;
var c = true;

Now it works fine!

Bye
MA

街角卖回忆 2024-10-23 02:36:27

我错过了将“var”放在变量声明前面,认为它解决了问题。

<script>
    uploadDocument = "Some message";
</script>

我将其修复为:

var uploadDocument = "Some message";

根本原因是我的表单中有一个具有相同 id“uploadDocument”的元素,因此上述声明导致 html 格式错误

I had missed to put 'var' in front of variable declaration, putting that it solved the issue.

<script>
    uploadDocument = "Some message";
</script>

I fixed it to :

var uploadDocument = "Some message";

Root cause was that I had an element in the form with the same id "uploadDocument", hence the above declaration was causing the html to be malformed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文