导入JQuery-Library会导致持续刷新网页

时间:2014-01-10 13:40:32

标签: javascript asp.net jquery refresh

我遇到了一个无法解释的问题

考虑html页面的后续负责人

<head runat="server">
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<style type="text/css">
</style>

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
    function ControleInput() {

        document.getElementById('Ophalen_button').disabled = true;
        document.getElementById('Wegschrijven_button').disabled = true;
        var allFields = true;

        //Controleren op de aanwezigheid van een FS-Nummer
        if (document.getElementById('FSNummer').value.length > 0) {
            document.getElementById('Ophalen_button').disabled = false;
        }
        else
        {allFields = false; }

        //Controleren op de aanwezigheid van een alias
        if (!document.getElementById('AliasPartner').value.length > 0)
        { allFields = false; }
        //Controleren op de aanwezigheid van een BTW-Nummer
        if (!document.getElementById('BtwNummerLeverancier').value.length > 0)
        { allFields = false; }
        //Controleren op de aanwezigheid van een afkorting
        if (!document.getElementById('Afkorting').value.length > 0)
        { allFields = false; }

        if (allFields) {
            document.getElementById('<%=Wegschrijven_button.ClientID %>').disabled = false;
        }
    }

    function ConfirmIgnoreBTWNbr() {
        if (confirm("Dit BTW-Nummer is reeds in gebruik. Deze zal bij het wegschrijven van gegevens worden overgeslagen. Is dit in orde?")) 
        {
            $.ajax({
                type: "GET",
                url: "SalesSetupHIC.aspx?action=sendData"
            })
        }
    }
</script>

page_behind(加载事件)上的代码

    Fouttekst.Text = String.Empty
    //enable disable some buttons and do some layoutactions

    Dim WindowsUser As String = Request.ServerVariables("LOGON_USER")
    t.Toegelaten(WindowsUser)
    If Not Page.IsPostBack Then

         //Perform some layoutactions

    End If

    //Get Some Data
    If (ListBoxBtwNummers.Items.Count = 0) Then
        ListBoxBtwNummers.DataSource = _myProxy.GetBTWNummersInGebruik(WindowsUser)
        ListBoxBtwNummers.DataBind()
    End If

    //Add some handlers
    FSNummer.Attributes.Add("onkeydown", "ControleInput()")
    AliasPartner.Attributes.Add("onkeydown", "ControleInput()")
    BtwNummerLeverancier.Attributes.Add("onkeydown", "ControleInput()")
    Afkorting.Attributes.Add("onkeydown", "ControleInput()")

    //If Querystring is present do something
    If (Request.QueryString.Count > 0) Then
        WegschrijvenData()
    End If

现在,当我使用以下页面访问页面时,此页面会对页面进行持续刷新:

 http://**MyPcName**/VirtualDirectory>/Default.aspx.
 http://**MyIP-Adres**/VirtualDirectory>/Default.aspx

但是当我访问

这样的页面时却没有
 http://**localhost**/VirtualDirectory>/Default.aspx
 http://**127.0.0.1**/VirtualDirectory>/Default.aspx

问题在于

 <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript">

删除库可解决刷新问题。但是阻止我使用ajax功能。我已经尝试了很多方法来包含图书馆,但到目前为止还没有运气。

所以关于这件事的问题是

1)为什么会不断刷新?

2)我如何解决这个问题?(虽然仍在使用JQuery ofc)

3)在这种情况下使用哪种调试器(Firebug / IE-Console)无法帮助

欢迎任何新想法。

由于

更新:引用另一个jquery的lib(本地和互联网)也没有解决问题。其他应用程序继续使用同一个lib而没有问题。

更新:使用Firebug / IE-Console进行调试并未导致任何解决方案。我还是卡住了。

1 个答案:

答案 0 :(得分:0)

经过一番痛苦的搜索后,我们终于找到了问题的根源。问题与Jquery或使用的方法没有任何关系。

原始开发人员使用VS2008创建了解决方案。但他没有“清理”他的HTML。由于依赖VS 2008,以下代码在html

中读取
<body id="PageBody" runat="server" bgcolor="#b0c4de" ms_positioning="GridLayout"
onresize="document.location=window.location;">

显然错误在于:onresize="document.location=window.location;" 删除此行dit可解决网页的不断闪烁问题。很可能Jquery在调整页面大小时会触发某个地方。

结束这件事:

  1. 永远不要依赖从VS生成的HTML(我知道)
  2. 永远不要依赖前辈写的HTML
  3. 感谢所有努力解决我的问题的人!