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脚本(上面两种方式都属于这种)
    使用超链接

    示例代码

    示例代码

  • 相关阅读:
    eclipse javaWeb项目如何引入jar包
    Unity3D 批量图片资源导入设置
    WaitForTargetFPS
    自适应分辨率
    UnityException: Texture is not readable
    Unity bundle的制作和使用
    Unity3D之Assetbundle
    Unity使用外部版本控制SVN
    AssetBundle机制相关资料收集
    Assetbundle的杂七杂八
  • 原文地址:https://www.cnblogs.com/Lulus/p/9917151.html
Copyright © 2011-2022 走看看