Ver Mensaje Individual
  #9 (permalink)  
Antiguo 03/05/2012, 11:59
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Codificación acentos Json y PHP

De hecho así es lo correcto, mira este script, ambos estan guardados como UTF8 sin BOM (usando Notepad++):
Código PHP:
Ver original
  1. <?php
  2. $registros = array(
  3.     array(
  4.         'name' => 'José',
  5.         'pais' => 'Colombia'
  6.     ),
  7.     array(
  8.         'name' => 'Juan',
  9.         'pais' => 'México',
  10.     ),
  11.     array(
  12.         'name' => 'Pedro',
  13.         'pais' => 'USA'
  14.     )
  15. );
  16.  
  17. header('Content-type: text/json');
  18. echo json_encode($registros);

Código HTML:
Ver original
  1.     <head>
  2.         <title>Test</title>
  3.         <script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5.     </head>
  6.     <body>
  7.         <div id="result"></div>
  8.     </body>
  9.     <script type="text/javascript">
  10.         jQuery(document).ready(function() {
  11.             jQuery.getJSON('json.php', function(response) {
  12.                 jQuery.each(response, function(i, result) {
  13.                     jQuery('#result').append('<p>' + result.name + ' => ' + result.pais + '</p>');
  14.                 });
  15.             });
  16.         });
  17.     </script>
  18. </html>