Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.09 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>AJAX - Cargar páginas con AJAX</title>
  6. <script type="text/javascript">
  7. function ajaxFunction() {
  8.   var xmlHttp;
  9.  
  10.   try {
  11.    
  12.     xmlHttp=new XMLHttpRequest();
  13.     return xmlHttp;
  14.   } catch (e) {
  15.    
  16.     try {
  17.       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  18.       return xmlHttp;
  19.     } catch (e) {
  20.      
  21.       try {
  22.         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  23.         return xmlHttp;
  24.       } catch (e) {
  25.         alert("Tu navegador no soporta AJAX!");
  26.         return false;
  27.       }}}
  28. }
  29.  
  30.  
  31.  
  32.  
  33. function Enviar(_pagina,capa) {
  34.     var ajax;
  35.     ajax = ajaxFunction();
  36.     ajax.open("POST", _pagina, true);
  37.     ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38.    
  39.    
  40.     console.log("Llamada AJAX");
  41.  
  42.     ajax.onreadystatechange = function() {
  43.         if (ajax.readyState==1){
  44.             document.getElementById(capa).innerHTML = " Aguarde por favor...";
  45.                  }
  46.         if (ajax.readyState == 4) {
  47.            
  48.                 document.getElementById(capa).innerHTML=ajax.responseText;
  49.              }}
  50.              
  51.     ajax.send(null);
  52. }
  53.  
  54.  
  55.  
  56. </script>
  57. <style type="text/css">
  58. img{border:none;}
  59. a{color:#000; text-decoration:none;}
  60. a:hover{text-decoration:underline;}
  61. body{background:#fff;
  62. font:14px Arial, Helvetica, sans-serif;
  63. margin:0;}
  64.  
  65. #contenedor{width:950px;
  66. margin: 0px auto;
  67. overflow:hidden;
  68. }
  69. #loading{
  70.  text-align:center;
  71. background:#6CBF19;
  72. color:#000;
  73. width:30%;
  74. margin:0px auto;
  75.   -moz-border-radius-bottomright:5px;
  76.   -moz-border-radius-bottomleft:5px;
  77.   -webkit-border-bottom-right-radius:5px;
  78.   -webkit-border-bottom-left-radius:5px;
  79.  
  80. }
  81. #loading2{
  82.  text-align:center;
  83. background:#000000;
  84. color:#fff;
  85. width:30%;
  86. margin:0px auto;
  87.   -moz-border-radius-bottomright:5px;
  88.   -moz-border-radius-bottomleft:5px;
  89.   -webkit-border-bottom-right-radius:5px;
  90.   -webkit-border-bottom-left-radius:5px;
  91.  
  92. }
  93. #contenido{
  94. float:right;
  95. padding:5px;
  96. width:750px;
  97. background:#F2F2F2;
  98. }
  99. #enlaces{float:left;}
  100. #encabezado{
  101. background:#999;
  102. list-style:none;
  103.   font-size:14px;
  104.   text-align:center;
  105.    color:#fff;
  106.    }
  107. ul{
  108. margin-top:-10px;
  109. width:150px;
  110. padding:10px;
  111. list-style:none;
  112. }
  113.  
  114. li{
  115. padding:2px;
  116. margin:3px 0px;
  117. width:150px;
  118. border:1px solid #000000;
  119. }
  120. li:hover{background:#EFFCE0;}
  121.  
  122. span.test { direction: rtl; unicode-bidi:bidi-override; }
  123.  
  124. li:first-child{
  125. font:bold 15px Geneva,Georgia;
  126. color:#CCCCCC;
  127. background:#666666;
  128. text-transform:uppercase;
  129. }
  130.  
  131.  
  132. </style>
  133. </head>
  134.  
  135. <body>
  136. <div id="contenedor">
  137.             <div id="encabezado">
  138.             <h1>AJAX: Cargar paginas con AJAX</h1>
  139.   </div>
  140.            
  141.   <ul id="enlaces">
  142.             <li>enlaces</li>
  143.             <li><a href="javascript:Enviar('<?php  base_url(); ?> Productos/mostrarNP','contenido')" title="Mi Biografia">Llamar Function del controlador</a></li>
  144.        
  145.             </ul>
  146.          
  147.             <div id="contenido">
  148.               <p><em><strong>Aca actualiza:</strong></em></p>
  149.              
  150.   </div>
  151.  
  152. </div>
  153.  
  154. </body>
  155. </html>
  156.  
  157.    <?php
  158.  
  159.   foreach($Producto_model as $producto){
  160.    
  161.                    echo $producto['np'] ;  
  162.  
  163.                }
  164.  
  165.    /*
  166.    
  167.            echo " <table align='center' border='1'> ";
  168.             echo "<tr><th>Prodcuto</th><th>Subrubro</th></tr> ";
  169.            
  170.             foreach($Producto_model as $producto){
  171.            
  172.                
  173.                     echo "<tr>";
  174.                     echo "<td align='center'>". $producto['np'] ."</td>" ;  
  175.                     echo "<td align='center'>". $producto['snp'] ."</td>" ;
  176.                     echo "<td align='center'>". $producto['pre'] ."</td>" ;                  
  177.                     echo "</tr>";
  178.                    
  179.                
  180.                    
  181.                 }
  182.                
  183.                 echo '</table>';
  184.                
  185.          */      
  186.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement