简体   繁体   English

'Sys'是未定义的JavaScript错误

[英]'Sys' is undefined javascript error

I am getting the following error: 我收到以下错误:

Microsoft JScript runtime error: 'Sys' is undefined Microsoft JScript运行时错误:“ Sys”未定义

While trying to execute: 尝试执行时:

<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">

        //ERROR IN THIS LINE!!!
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onUpdated());


          function onUpdated() {
                // get the update progress div
                var pnlPopup = $get("div2"); 
                // make it invisible

            }

    </script>
</head>

Ensure you have a Scriptmanager on the page and the script is below the scriptmanager. 确保页面上有一个Scriptmanager,并且脚本在scriptmanager下方。 Maybe try to put your script tag into body and see what happens. 也许尝试将您的脚本标签放入正文中,看看会发生什么。

I don't know how you can fix that that its not in the body, but maybe there is a callback from Sys when its loaded 我不知道如何解决它不在体内的问题,但是加载Sys时可能会有回调

You don't need brackets to tell which function is neeeded: 您无需使用括号即可知道需要选择哪个函数:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onUpdated);

If that is your full code, then the problem is that the Microsoft AJAX libraries aren't being included. 如果这是您的完整代码,那么问题是未包含Microsoft AJAX库。 If it isn't your full code, then you need to post more as it's a little hard to get beyond the fact that the library isn't included. 如果这不是您的完整代码,则您需要发布更多代码,因为要超出不包含该库的事实有点困难。 Somewhere in your file -- prior to the line you are having problems with you need to have a javascript include like: 在文件中的某处-在出现问题之前,您需要使用JavaScript,例如:

<script type="text/javascript" src="/scripts/MicrosoftAjax.js" />

As well as probably a few others. 以及其他一些人。

Note: I'm talking about the generated source. 注意:我说的是生成的源。 Showing more complete markup would probably also suffice. 显示更完整的标记可能也足够了。

I'm a bit late to the discussion here, but a simple solution is to create a "ASP.NET AJAX-Enabled Web Site" in Visual Studio and then merge the web.config from that site with your existing site. 我在这里进行讨论有点晚了,但是一个简单的解决方案是在Visual Studio中创建一个“支持ASP.NET AJAX的网站”,然后将该站点中的web.config与您现有的站点合并。

In this way you get all the configuration you need without having to carefully read through a lot of docs. 这样,您无需仔细阅读大量文档即可获得所需的所有配置。 Speed is of the essence and all that :) 速度至关重要:)

您可以通过将EnableCDN属性设置为“ true”来解决此问题。请参阅此链接

I had the same issue , after all findings I found that the required script files ("MicrosoftAjax.js", "WebForms.js","jquery", "bootstrap" etc..) were not loaded properly which was causing me 3 errors "Sys' is undefined", "webform_docallback is undefined" and "webform_initcallback' is undefined", my actual problem was I had reference to these files which where not included in my propject, my bad I have not noticed it, I have tried all the possible solutions from the internet before I really found that my js files were not included and thats the reason its not loaded properly. 我遇到了同样的问题,所有发现之后,我发现所需的脚本文件(“ MicrosoftAjax.js”,“ WebForms.js”,“ jquery”,“ bootstrap”等)未正确加载,这导致了3个错误“ Sys'是未定义的”,“ webform_docallback是未定义的”和“ webform_initcallback'是未定义的”,我的实际问题是我引用了这些文件,这些文件未包含在我的项目中,很糟糕,我没有注意到,我已经尝试了所有在我真正发现我的js文件未包括在内之前,可以从互联网上找到可能的解决方案,这就是其未正确加载的原因。

Hope this helps.. 希望这可以帮助..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM