十 Django 1.5.4 jQuery

51 篇文章 1 订阅
11 篇文章 0 订阅


一.base.html

<!DOCTYPE html>
<html lang="es">
  <head>
    <meta charset="utf-8">
    <title>Proyecto Demo</title>
    <!-- Le styles -->
    <link href="/media/bootstrap/css/bootstrap.css" rel="stylesheet">
     <link href="/media/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <script src="/media/js/jquery.js"></script>
    <script src="/media/bootstrap/js/bootstrap.js"></script>
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      .sidebar-nav {
        padding: 9px 0;
      }
    </style>
    <script type="text/javascript">
        $(document).on('ready',function(){
              $.ajax({
                  type:"GET",
                  contentType:"application/json; charset=utf-8",
                  dateType:"json",
                  url:"/ws/productos/",
                  success:function(response){
                          var i = (response.length-1)-2;
                          for(i;i<=(response.length-1);i++){
                              $('#ProductosNuevos').append("<li>"+response[i].fields.nombre+"</li>");
                          }
                  }
              });
        });
    </script>
  </head>
  <body>
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
          <a class="brand" href="{% url vista_principal %}">Proyecto Ventas </a>
            {% if user.is_authenticated %}
            <p class="navbar-text pull-right">
              Logged in as {{ user.username }}
            </p>
            {% endif %}
            <ul class="nav">
              <li><a href="/productos/page/1/">Productos</a></li>
              <li><a href="{% url vista_contacto %}">Contacto</a></li>
              <li><a href="{% url vista_about %}">Acerca de ...</a></li>
              {% if user.is_authenticated %}
                                <li><a href="{% url vista_logout %}"> Cerrar Sesion </a></li>
                {% else %}
                                <li><a href="{% url vista_login %}"> Login </a></li>
                {% endif %}
        </div>
      </div>
    </div>

    <div class="container-fluid">
      <div class="row-fluid">
        <div class="span9">
          <div class="hero-unit">
            {% block content %}
            {% endblock%}
          </div>
        </div><!--/span-->
        <div class="span3">
          <div class="well sidebar-nav">
            <ul class="nav nav-list">
              <li class="nav-header">Mi Carrito</li>
              <br><p align="justify">
                      Carrito de Super
              </p>
            </ul>
          </div><!--/.well -->
          <div class="well sidebar-nav">
            <ul class="nav nav-list" id="ProductosNuevos">
              <li class="nav-header">Nuevos Productos</li>
              
            </ul>
          </div><!--/.well -->
           <img src="/media/images/django.gif"/>
        </div><!--/span-->
      </div><!--/row-->
      <hr>
      <footer>
        <p>© Open Project 2013 </p>
      </footer>
    </div><!--/.fluid-container-->
    <!-- Le javascript
================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
  </body>
</html>

可以先把回复输出到控制台,在Firebug中调试


还可以查看JSON格式



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值