javascript 分配 onreadystatechange 时类型不匹配错误是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9789500/
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
What is a type mismatch error mean when assigning onreadystatechange?
提问by GC_
What is a JavaScript type mismatch error?
什么是 JavaScript 类型不匹配错误?
And what are the likely causes?
可能的原因是什么?
I can't include all the code, but here is the line that gets the error.
我不能包括所有的代码,但这里是出现错误的行。
xmlObject.onreadystatechange = null;
回答by bfavaretto
You are getting the error because xmlObject.onreadystatechange
expects a function, but you are assigning null
to it. This should fix it:
您收到错误是因为xmlObject.onreadystatechange
需要一个函数,但您正在分配null
给它。这应该解决它:
xmlObject.onreadystatechange = function() {
// handle the readystatechange event here
}