调用 ASP.NET AJAX WebServiceProxy.invoke() Javascript 方法时出现问题
我编写的一些代码有问题。 我不得不匿名,但我可以提出问题。 该 JavaScript 在 iframe 内运行,并且是实例化对象的一部分。 特别是问题是,每次在 invoke() 调用中“类型‘对象’无法转换为类型‘函数’”时,我都会收到重复错误。 但是,在 IE8 开发人员插件中,检查我传递的函数的 typeof (this.AJAXCallback),它清楚地表明这是一个正在传递的函数。 发生此错误有什么特殊原因吗?
MyObject.prototype.AJAXCallback=function(Data, e){
//snip
};
MyObject.prototype.Init=function(){
var a = window.top.window.Sys.Net.WebServiceProxy.invoke('/Data.asmx', 'GetData', false, { "IDCode":0 }, this.AJAXCallback, null);
//snip
};
I'm having a problem with some code I've written. I've had to anonymize it, but I can give the problem. This javascript runs inside an iframe, and is part of an object that gets instantiated. The problem in particular is that I get a repeating error every time that "Type 'Object' Cannot be converted to type 'Function'" in the invoke() call. However, in the IE8 developer addon, checking the typeof of the function I pass (this.AJAXCallback), it clearly says that it's a function being passed. Is there any particular reason this error might be occurring?
MyObject.prototype.AJAXCallback=function(Data, e){
//snip
};
MyObject.prototype.Init=function(){
var a = window.top.window.Sys.Net.WebServiceProxy.invoke('/Data.asmx', 'GetData', false, { "IDCode":0 }, this.AJAXCallback, null);
//snip
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现问题了,看来不是我的问题。 我在 web.config 文件中禁用了调试,错误停止了。 打开调试后它也会返回,所以我认为可以肯定地说,调试代码与我编写的代码的工作效果不如非调试代码。 特别是,它是脚本管理器的 JS 文件之一。
I found the problem, and it doesn't seem to be on my part. I disabled debugging in the web.config file, and the error stopped. It also came back after debug was turned on, so I think it's safe to say that the debug code didn't work as well with what I wrote as the non-debug code did. In particular, it was one of the scriptmanager's JS files.
它可能会产生问题,因为回调是一个原型。 您是否尝试过将回调包装在匿名函数调用中。
It may be giving issues because the Callback is a prototype. Have you tried wrapping the callback in an anonymous function call.