English 中文(简体)
有效载荷
原标题:.load() kills character encoding
  • 时间:2011-10-28 01:02:08
  •  标签:
  • jquery

I m using the following code to load in content:

<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function(){
        jQuery( .content-div ).load("all-events.html");     
    });
</script>

However the content is loaded in without the special characters that I want in UTF-8. It was mentioned somewhere to put this at the top of my code:

$html = header( Content-Type: text/html; charset=utf-8 ); 

However I only got this error: header is not defined .

最佳回答

然而,由于大家的帮助,我发现问题是什么。 问题在于,在基本文本档案中添加<代码>标题<>t/code>,从而改变其实际编码。 我写了该笔记本,没有办法核对编码是否正确。 接着,我宣布开始发言。 Notepad++ and set the encoding from that application. 希望帮助那些努力解决这一问题的人:

问题回答

I was experiencing the same problem, but the original poster s accepted answer didn t help. Doing one of the bellow actions solved it for me:

  1. Changing the retrieved document s extension from ".html" to ".php".

  2. 在主页主编上添加“<>条码>。

    AddDefaultCharset UTF-8
    
  3. 上文两段的合并


更深入地探讨这一问题:

检查反应和请灭火器头盔,可以看到服务器(Apache)正在退回在ISO-8859-1号园区编码的内容。 我所需要的是UTF-8。

尽管所有档案都是在没有管理局的情况下被编码为UTF-8,

 header("Content-Type: text/html; charset=utf-8");

正如Mike Haboustak所指出的,在主要档案中,有活力地包括: html 文档,其内容被过滤,因为j Query使用浏览器.inner/2006/2 的财产,以复制检索的文件并插入本文件。 见。 详情请上

j Query s load() 方法使用浏览器的内心超文本执行方式将请求中退回的html装入本文件。 这意味着即将到来的html必须使用与本文件相同的文本。 页: 1 缩略语

You need to fix this at the server, not in Javascript. The server-side code that is responding with your original Html (that contains your jQuery) needs to include a content-type header with the right character encoding. If you re using Php, I think you ve found an example of how to do that.





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...