zoukankan      html  css  js  c++  java
  • asp .net 页面跳转

    ajax异步

    通过ajax去请求数据,然后在js里面得到返回结果,赋值location.href

    <div>
        <input id="url" />
        <button onclick="RedirectByAjax()">跳转页面</button>
    </div>
    
    <script>
        function RedirectByAjax() {
            //ajax请求完成一些工作
            $.ajax({
                type: "POST",
                url: "/RedirectUrl/RedirectByAjax",
                data: {
                    url: $("#url").val()
                },
                success: function (url) {
                    //得到结果,跳转页面
                    location.href = url;
                }
            });
        }
    </script>
    

    form同步

    通过post form表单提交数据,然后在表单对应的Action里面调用Redirect

    <form id="redirectForm" name="redirectForm" action="/RedirectUrl/RedirectByForm" method="post">
        <div>
            <input id="url" name="url" />
            <button id="submit" onclick="Submit()">登录</button>
        </div>
    </form>
    
    <script>
        function Submit() {
            $("#redirectForm").submit();
        }
    </script>
    
    [HttpPost]
    public ActionResult RedirectByForm(string url)
    {
        return Redirect(url);
    }
    

    注意

    二者不可混用,比如ajax请求+Redirect,这样返回的页面在Network请求里面,而不是实现跳转页面

    其他

    使用Response.Redirect 方法
    使用Server.Transfer方法
    使用Server.Execute 方法
    使用javascript脚本(上面两种方式都属于这种)
    使用超链接

    示例代码

    示例代码

  • 相关阅读:
    常用数据库种类 以及优缺点
    数据库
    Python中os与sys两模块的区别
    python操作数据库
    python——解释型语言
    面向对象的三大特性
    Android Fastboot 与 Recovery 和刷机 千山万水迷了鹿
    selenium与appium怎样联系
    Pycharm快捷键
    uiautomator python版本
  • 原文地址:https://www.cnblogs.com/Lulus/p/9917151.html
Copyright © 2011-2022 走看看