简体   繁体   English

经典ASP和JQuery在重定向时重新加载default.asp页

[英]Classic ASP and JQuery reloads default.asp page on redirect

I have integrated an existing Classic ASP site with JQuery (they were using VBScript before). 我已经将现有的Classic ASP站点与JQuery集成在一起(它们之前使用的是VBScript)。 The previous version works fine but the script's needed to be updated so it will work on other browsers. 以前的版本运行良好,但是需要更新脚本,以便在其他浏览器上运行。 But when I redirect the page with JQuery integrated, the system loads the default.asp file and the second URL. 但是,当我使用集成的JQuery重定向页面时,系统会加载default.asp文件和第二个URL。 The address bar also shows the default url. 地址栏还会显示默认网址。

How can I prevent this? 我该如何预防?

When I use the window.open('url') , it opens the correct page with the correct URL but I have 2 tabs open. 当我使用window.open('url') ,它将使用正确的URL打开正确的页面,但是我打开了2个标签。 When I use window.open('url', '_self') it still redirects to the problematic page. 当我使用window.open('url', '_self')它仍然重定向到有问题的页面。

PS Response.Redirect 'url' and window.open('url', '_self') give the same results. PS Response.Redirect 'url'window.open('url', '_self')给出相同的结果。

Edit: Here's some of the code used 编辑:这是一些使用的代码

Here's the main frame JS (submit function) that loads within the default.asp 这是在default.asp中加载的主要框架JS(提交功能)

$("img[name=cmdLog]").click(function(){
            $("form[name=frmLogIn]").target = "_top";
            $("form[name=frmLogIn]").get(0).setAttribute("action", "ValidateUser.asp");
            $("form[name=frmLogIn]").submit();
        });

Here's ValidateUser.asp (without the updated JS, using only VBScript) 这是ValidateUser.asp (不使用更新的JS,仅使用VBScript)

<form name="frmValidate" method="post">
    <%
        Session("PMISConnString")="Provider=SQLOLEDB;Server=192.168.x.x;User ID=sa;PWD=x;Database=DB"
        dim conn, rsEmp, SQLQuery, m_Code,i,lenStr,newCode,rsUser
        set conn=Server.CreateObject("ADODB.Connection")

        m_Code=Request.Form("txtEmpID")
        lenStr=len(m_code)
        newCode=""
        for i=1 to lenStr
            if mid(m_Code,i,1)="'" then
                newCode=newCode & "''"
            else
                newCode=newCode & mid(m_Code,i,1)
            end if
        next 


        conn.Open=Session("PMISConnString")

        dim clsCrypt
        dim url
        set clsCrypt=Server.CreateObject("ChiperText.clsChiperText")

        SQLQuery="SELECT UserCode, Pwd "
        SQLQuery=SQLQuery & "FROM Users "
        SQLQuery=SQLQuery & "WHERE UserCode='" & clsCrypt.ChiperText(lcase(newCode)) & "'"

        set rsUser=Server.CreateObject("ADODB.Recordset")
        rsUser.Open SQLQuery,conn

        if rsUser.EOF then
            url = "ErrorPage.asp?TYPE=6"
        elseif rsUser.Fields("Pwd")<>clsCrypt.ChiperText(Request.Form("txtEmpPassword")) then
            url = "ErrorPage.asp?TYPE=7"
        end if

        SQLQuery="SELECT EmpID,EmpFirst,EmpLast,dbo.GetCapitalChars(Employee.EmpMid) AS MidInitial From Employee WHERE EmpID='" & newCode & "' "
        SQLQuery=SQLQuery & "AND EmpActive=1 "

        set rsEmp=Server.CreateObject("ADODB.Recordset")
        rsEmp.Open SQLQuery,conn
        if not rsEmp.EOF then
            Session("EmpID")=Request.Form("txtEmpID") 
            Session("MyName")=rsEmp.Fields("EmpFirst") & " " & rsEmp.Fields("MidInitial") & " " & rsEmp.Fields("EmpLast")
            'varServer="http://" + Request.ServerVariables("SERVER_NAME") + "/" + Session("VirtualName") + "/"

            Response.Cookies("Site")="http://" + Request.ServerVariables("SERVER_NAME") + "/" + "PMIS"

            Session("Server")="http://" + Request.ServerVariables("SERVER_NAME") + "/" + "PMIS"
            Session("ImgFolder")="http://" + Request.ServerVariables("SERVER_NAME") + "/" + "PMIS/Images/" 'full path ng images folder under PMIS directory
            url = "main2.asp"
        else
            url = "ErrorPage.asp?TYPE=1"
        end if

        Response.Redirect(url)
        rsEmp.Close
        Set rsEmp=Nothing
        set clsCrypt=Nothing
        conn.Close
        set conn=Nothing
    %>
</form>

如果在框架集中,请考虑使用JavaScript将window.top.location.href更改为您的重定向URL。

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

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