2015-07-13 42 views
0

I'm加載稱爲descripcion.txt一個文本文件,並在我的div顯示它出現的所謂#descripcionContenedor,但是當它被顯示在瀏覽器aparently UTF-8是不工作,因爲即時得到「 」而不是「¿」。 這裏是我的代碼:時加載文本文件與jQuery

jQuery的文件:

$(document).ready(function() { 
$("#description").ready(function() { 
    $.ajax({ 
     url : "textFiles/descripcion.txt", 
     dataType: "text", 
     contentType: "charset=utf-8", 
     success : function (data) { 
      $("#description").html(data); 
     } 
    }); 
}); 
}); 

TXT文件:

<meta content="text/html; charset=UTF-8" /> 
<h2 style="margin-bottom: 0;">¿Que es esta pagina web?</h2></br> 

PHP文件:

<head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
    </head> 
    <body> 
      <div id="descripcionContenedor"> 
       <p id="description"></p> 
    </body> 

回答

0

當保存的文本文件(使用Windows記事本) ,確保編碼設置正確。

你也可以簡單地&iquest;的HTML實體替換所有問號。這樣,編碼就無關緊要(當涉及數據庫時,它也更容易)。

+0

是它的工作謝謝 – reojased