zoukankan      html  css  js  c++  java
  • IFrame实现的无刷新(仿ajax效果)...

    前台代码:

    <iframe style="display:none;" name="gg"></iframe>
            <form action="/demo/add" method="post" target="gg">
                <table class="info_form table table-striped">
                    <tr>
                        <td>姓名</td>
                        <td><input name="name" /></td>
                    </tr>
                    <tr>
                        <td>年龄</td>
                        <td><input name="age" /></td>
                    </tr>
                    <tr>
                        <td>颜值</td>
                        <td><input name="yz" /></td>
                    </tr>
                </table>
                <button class="btn btn-default" type="submit">确定</button>
            </form>
    <script>
    function call_back(){
      alert("睡你妈逼,起来嗨!");
    }
    </script>
    注意:form的target属性。设置为iframe的name属性值。这样的话后台返回的view会显示在iframe中

    后台代码:

    public ActionResult Add()
            {
                return View();
            }
            [HttpPost]
            public ActionResult Add(my m)
            {
                testEntities t = new testEntities();
                t.my.Add(m);
                t.SaveChanges();
                return Content("<script>parent.call_back();</script>");
            }

    这样页面不会刷新。也可以调js方法。。。。不想用ajax的话。用这个也是不错的选择

  • 相关阅读:
    python_6
    python_day4
    python_day3
    python_day2
    python
    python入门
    jQuery之前端国际化jQuery.i18n.properties
    转载!网页中插入百度地图
    jQuery.validate 中文API
    Web移动端Fixed布局的解决方案
  • 原文地址:https://www.cnblogs.com/gaocong/p/4766132.html
Copyright © 2011-2022 走看看