What to do when jquery reads txt garbled characters

藏色散人
Release: 2021-11-11 09:40:28
Original
2410 people have browsed it

The solution to jquery reading garbled txt: 1. Load the page; 2. Execute the code "function (xhr){xhr.overrideMimeType('text/plain; charset=gb2312')..." .

What to do when jquery reads txt garbled characters

The operating environment of this article: windows7 system, jquery3.2.1 version, DELL G3 computer

#What should I do if jquery reads txt garbled characters?

The text read out by jquery.load is garbled

Loading txt, Chinese garbled characters

$("#divattach").load(attachpath, function (data) { $("#contentID").html(data); });
Copy after login

Loading on the page After completion, execute this code

$(function () { $.ajaxSetup({ 'beforeSend': function (xhr) { xhr.overrideMimeType('text/plain; charset=gb2312'); } }); });
Copy after login

Recommended learning: "jquery video tutorial"

The above is the detailed content of What to do when jquery reads txt garbled characters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!