2012-10-31 58 views
2

我遇到此问题: 我尝试从.json文件加载数据到我的网站,但我遇到了标题中特殊字符的问题(Ó ,Í,É,空间)。我只能更改.HTML文件。我已经tryed这是html的:http://www.lukcian.x10.mx/json5.html

感谢

这是一个例子:

以.json:

{ 
    "Bibliotecas": [ 
     { 
      "BIBLIOTECA": "Biblioteca General de Navarra ", 
      "DIRECCIÓN ": "Plaza de San Francisco", 
      "COD. POSTAL": 31001, 
      "POBLACIÓN": "Pamplona", 
      "TELÉFONO": 848427797, 
      ..................... 

的.html:

<!DOCTYPE HTML> 
<html> 
    <head> 
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> 

    <title>JSON multiple zombies 
    </title> 

    <script src="HostFiles/jquery.js"></script> 
    <link href="reset.css" rel="stylesheet" type="text/css" media="screen"> 




    <script> 


     $(document).ready(function() { 
       $.getJSON('json/bibliotecas.json', function(json) { 

       $.each(json.Bibliotecas, function() { 

       $('<article class="json"></article>').append(

       '<p> ' + this.BIBLIOTECA + '</p>' + 
       '<p> ' + this["DIRECCIÓN "] + '</p>' + 
       '<p> ' + this.POBLACIÓN + '</p>' + 
       '<p> ' + this.TELÉFONO + '</p>' + 


       '</br></br>' 
       ).appendTo('body'); 


    });   

    }); 

}); 





    </script> 





</head> 
<body> 

</body> 
    </html> 

结果:

Biblioteca General de Navarra 

undefined 

undefined 

undefined 

回答

1

您试图显示Unicode字符。如果您需要Unicode提供的额外字符,则需要更改字符集

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> 

               ^change to charset=utf-8" 

Reference: W3C Charset

+0

我有此charset allso tryes。它仍然不起作用 –

+0

当浏览器显示页面时,你可以检查页面源代码的样子吗? –

+0

是的。这是.json文件源代码:http://www.lukcian.x10.mx/json/bibliotecas.json –