zoukankan      html  css  js  c++  java
  • Phyton Flask框架学习记录。

       注意:在左侧菜单栏(在JQuery插件库下载的)右边是采用<iframe> 标签嵌入其他页面,此时标签的src应用用后台中的方法名称(本人测试用的是无参数的方法),

    而页面跳转window.location.href和<a>标签的href的url必须是后台路由名称。

    1,首先是在左侧菜单栏中加了一个<a>标签,并且写了个调用后台返回infor.html页面的js方法:

    <a href="javascript:void(0)" id="btninfor22" onclick="showdata()" style="font-style: initial;background-color: #d6e9c6"> 学生信息表</a>
     function showdata() {
    
                 $.get("/infor", {"hno": "123"},
                     function (data, status) {
                         if (data != "undefined" && data != "insertok") {
                             //$("#content").html(data);
                             //src里url是后台里的方法名称。而<a>标签里href的地址是后台路由名称
                             $("#content").html('<iframe style=" 1100px;height: 600px" src="{{ url_for('py_infor')}}" id="myiframe"  frameborder="0"></iframe>');
                         }
                         else {
                             alert("插入失败,状态:" + status);
                         }
                     });
             }

    2.其次在左侧菜单栏右边放了个<div>:

    <div class="container" style="background-color: #e6e6e6" id="content">
        <p>右侧内容</p>
    </div>

    3.最后在后台中写好方法(py_infor()):

    @app.route('/infor') #页面链接该路由名称
    def py_infor():
        # //查询数据
        getsql = "SELECT * FROM dbo.infor"
        inforlist = getdata(getsql)
        return render_template('infor.html', inforlist=inforlist)
        return render_template('infor.html')  # send_file('/templates/testhtm.html') #

     2018.7.24  added by longdb

    window.open()打开个新页面:url必须是后台方法名称。

                window.open('{{url_for("py_getaddinfor") }}','_blank','width=500px,height=500px,resizable=0,scrollbars=auto');

    2018.7.25 added by longdb

    在一个页面中插入另外一个页面:

    
    
    <div class="container" style="background-color: #e6e6e6" id="content">
        <p>右侧内容</p>
        {% include "editaddinforview.html" %}
    </div>
    
    
    
    
    

    最后效果:

  • 相关阅读:
    js配置文件路径和项目目录文件夹位置的一致性
    MyBatis DTD文件下载地址
    Maven安装问题
    WebService客户端(以命令方式创建)
    Error configuring application listener of class org.springframework.web.cont
    HashMap与LinkedHashMap的区别
    同一台电脑配置多个JBoss
    WebService之客户端
    【solvebug】Java反射报错java.beans.IntrospectionException: Method not found,lombok的@Accessors注解
    【运维】windows server 2008 R2 Standard中如何安装 mysql8.0
  • 原文地址:https://www.cnblogs.com/longdb/p/9350165.html
Copyright © 2011-2022 走看看