简体   繁体   English

jQuery ajax方法在Internet Explorer中不起作用

[英]jQuery ajax method does not work in Internet Explorer

I have the following piece of jQuery code working in every browser (Firefox, Chrome, Opera) but is not working in Internet Explorer. 我在所有浏览器(Firefox,Chrome,Opera)中都可以使用以下jQuery代码,但在Internet Explorer中却无法使用。 It's a div with a shopping cart and is showing the products in Chinese. 这是一个带购物车的div,并以中文显示产品。 But when it comes to Internet Explorer it shows squares instead of the Chinese characters (horror story). 但是,对于Internet Explorer,它显示的是正方形而不是中文(恐怖故事)。

Any ideas what I'm doing wrong or how to fix it? 有任何想法我在做什么错或如何解决?

function geturl(addr,mydata) {  
    var r = $.ajax({  
    type: 'GET',  
    url: addr, 
    data: mydata, 
    contentType: "text/html; charset=UTF-8",
    scriptCharset: "utf-8" ,
    async: false  
    }).responseText;  
return r;  
 }  

It even works in Firefox, Chrome and Opera without the lines: 它甚至可以在Firefox,Chrome和Opera中运行,而无需执行以下操作:

    contentType: "text/html; charset=UTF-8",
    scriptCharset: "utf-8" ,

I've just added those 2 lines to see if that was the problem in IE. 我刚刚添加了这两行,以查看这是否是IE中的问题。

Thanks in advance. 提前致谢。

IE always have a problem that doesn't have another browser. IE始终存在没有其他浏览器的问题。 Try with this link (only for client). 尝试使用此链接 (仅适用于客户端)。

Now, for your ajax request, I don't know if htmlentities.js can be applicable for chinese charset. 现在,对于您的Ajax请求,我不知道htmlentities.js是否可以适用于中文字符集。 Might be better that before sending the result of the ajax request transform the info into html entities (in php you can use htmlentities() ) 最好在发送ajax请求的结果之前将信息转换为html实体(在php中,您可以使用htmlentities()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM