问题
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
回答1:
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.
回答2:
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:
- Look for any AJAX calls and look for an extra comma.
- Look for any arrays (like stuff in curly braces) where there's an extra comma at the end.
- 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. - Move to the latest version of jQuery.
- 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.
回答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/
回答4:
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.
回答5:
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.
回答6:
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.
回答7:
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
回答8:
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.
回答9:
Are you by any chance including a js file ?
Because
Error 80020101 means that IE isnt't able to compile your script.
回答10:
Got this error for a different issue while using jquery.
Change $(document).ready(function(){}); TO $(window).load(function(){});
回答11:
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.
回答12:
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.
回答13:
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
回答14:
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
来源:https://stackoverflow.com/questions/4918969/ajax-request-problem-error-80020101