2013-02-11 29 views
1

我必須寫一個jquery函數來獲取網頁,然後在div中顯示它。如何在適當的字符集中獲得ajax響應?

    $.ajax({ 
        beforeSend : function(xhr) { 
         xhr.overrideMimeType("text/html; charset="+document.characterSet); 
         xhr.setRequestHeader("Content-type","text/html; charset="+document.characterSet); 
        }, 
        CcntentType:"text/html; charset="+document.characterSet, 
        type: "GET", 
        url: destination, 
        statusCode: { 
        200: function(response){ 
          callback(response); 
        } 
        }, 
        error: function() { 
        // default behavior       

        } 
       }); 

,但是當我在html插入接收到的數據,我得到了一些有趣的符號 - rectanges和?

我在其中執行ajax請求的頁面具有元標記。 我沒有訪問頁面,我正在做的Ajax請求,所以我不能改變它。

字符集是windows-1251,只發生在IE10中,在Firefox和鉻一切正常。

如何解決?

回答

0

我會嘗試的第一件事是將您自己的頁面的字符集更改爲您所調用的頁面。