Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/10/2012, 18:40
Avatar de truman_truman
truman_truman
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: duda sobre json

En mi opinion Json se puese usar en donde antes usabas xml, por ejemplo.

Yo lo uso pura y exclusivamente para hacer consultas con ajax.

Segun lei es muy rapido.

Como mezclarlo:



index.php
Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. $(function(){
  3.  
  4.  
  5. $.ajax({
  6.                   type: 'POST',
  7.                   url: 'test.php',
  8.                   dataType: 'json',
  9.                   success: function(data){
  10.                       if(data.error == 0)
  11.                       {
  12.                          
  13.                             alert("Exito");
  14.                                              
  15.                          
  16.                       }else{
  17.                          
  18.                             alert("Error");
  19.                          
  20.                       }
  21.                   }
  22.                 });
  23.  
  24.  
  25.  
  26. });


test.php
Código PHP:
Ver original
  1. <?php
  2.                 $resultado = array();
  3.                 $resultado['error'] = 0;
  4.                 print_r(json_encode($resultado));
  5.                 exit;
  6.  
  7.  
  8. ?>
__________________
la la la