Home Backend Development PHP Tutorial Solve the problem of garbled Chinese characters in ajax interaction on pages encoded as gb2312_PHP tutorial

Solve the problem of garbled Chinese characters in ajax interaction on pages encoded as gb2312_PHP tutorial

Jul 13, 2016 am 10:54 AM
ajax for Garbled characters interaction Chinese character coding solve question page

Solve the problem of garbled Chinese characters in ajax interaction on pages encoded as gb2312
Ajax only supports utf-8 format and cannot support gb2312 encoding format, so we often encounter garbled characters when using gb2312 encoding programs using ajax. I just found a solution:

The data transmitted by the server is still gb2312 encoded, and the client uses js to convert Chinese characters into utf8 encoding and display it on the page

search.php tutorial
header("content-type: text/html; charset=gb2312");
include './search.htm';
?>

search.htm




Advanced Search


Advanced Search



School type:

School name:




ajax.php

header("content-type: text/html; charset=gb2312");
$schooltype = !empty($_post['schooltype']) ? $_post['schooltype'] : 0;
switch($schooltype) {
case 0:
echo "[['40', 'Taipingxi Town Hualibao Complete Primary School'],['41', 'Taipingxi Town Changling Heilongjiang Hope Primary School'],['42', 'Letianxi Town Junior High School'], ['43', 'Letianxi Town Liantuo Junior High School']]";
         break;
Case 1:
echo "[['40', 'Taipingxi Town Hualibao Complete Primary School'],['41', 'Taipingxi Town Changling Heilongjiang Hope Primary School']]";
         break;
Case 2:
echo "[['42', 'Lotte Creek Town Junior High School'],['43', 'Lotte Creek Town Liantuo Junior High School']]";
         break;
Default:
         break;
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632334.htmlTechArticleSolve the problem of garbled Chinese characters in ajax interaction on pages encoded as gb2312. Ajax only supports utf-8 format and cannot support gb2312 encoding format. Therefore, we often encounter garbled codes when using ajax in programs encoded by gb2312...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Five tips to teach you how to solve the problem of Black Shark phone not turning on! Five tips to teach you how to solve the problem of Black Shark phone not turning on! Mar 24, 2024 pm 12:27 PM

As smartphone technology continues to develop, mobile phones play an increasingly important role in our daily lives. As a flagship phone focusing on gaming performance, the Black Shark phone is highly favored by players. However, sometimes we also face the situation that the Black Shark phone cannot be turned on. At this time, we need to take some measures to solve this problem. Next, let us share five tips to teach you how to solve the problem of Black Shark phone not turning on: Step 1: Check the battery power. First, make sure your Black Shark phone has enough power. It may be because the phone battery is exhausted

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? Mar 22, 2024 am 08:06 AM

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

The driver cannot be loaded on this device. How to solve it? (Personally tested and valid) The driver cannot be loaded on this device. How to solve it? (Personally tested and valid) Mar 14, 2024 pm 09:00 PM

Everyone knows that if the computer cannot load the driver, the device may not work properly or interact with the computer correctly. So how do we solve the problem when a prompt box pops up on the computer that the driver cannot be loaded on this device? The editor below will teach you two ways to easily solve the problem. Unable to load the driver on this device Solution 1. Search for "Kernel Isolation" in the Start menu. 2. Turn off Memory Integrity, and it will prompt "Memory Integrity has been turned off. Your device may be vulnerable." Click behind to ignore it, and it will not affect the use. 3. The problem can be solved after restarting the machine.

How to implement page jump in 3 seconds: PHP Programming Guide How to implement page jump in 3 seconds: PHP Programming Guide Mar 25, 2024 am 10:42 AM

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of

How to deal with garbled characters in Linux terminal How to deal with garbled characters in Linux terminal Mar 20, 2024 pm 03:12 PM

How to deal with the problem of garbled characters in the Linux terminal. When using the Linux system, sometimes the text displayed in the terminal will be garbled. This brings inconvenience to us when using the terminal and needs to be dealt with in time. This article will introduce how to deal with some common Linux terminal garbled problems, and provide specific code examples. Problem 1: Garbled Chinese characters on the terminal. Garbled Chinese characters on the terminal are usually caused by incorrect character encoding settings on the terminal. We can solve this problem by modifying the terminal's character encoding settings. #View the current terminal

Black Shark mobile phone charging troubleshooting and solutions Black Shark mobile phone charging troubleshooting and solutions Mar 22, 2024 pm 09:03 PM

Black Shark is a smartphone brand known for its powerful performance and excellent gaming experience. It is loved by gamers and technology enthusiasts. However, just like other smartphones, Black Shark phones will have various problems, among which charging failure is a common one. Charging failure will not only affect the normal use of the mobile phone, but may also cause more serious problems, so it is very important to solve the charging problem in time. This article will start with the common causes of Black Shark mobile phone charging failures and introduce methods to troubleshoot and solve charging problems. I hope it can help readers solve the problem of Black Shark mobile phones.

Simple steps: Solve the problem that the Chinese interface of VSCode cannot be displayed Simple steps: Solve the problem that the Chinese interface of VSCode cannot be displayed Mar 25, 2024 am 11:57 AM

My steps are as follows: Solve the problem that the Chinese interface of VSCode cannot be displayed. Some people found after installing VSCode that no matter what language was set, the interface was always displayed as a box or garbled characters, which was very troublesome. This is often caused by a lack of language support packages or font issues on the system. Below I will share some simple solution steps to help you fix the problem that the Chinese interface of VSCode cannot be displayed. Step 1: Install the Chinese language pack First, we need to install the Chinese language pack for VSCode. Open VSCode and click on the lower left corner

Introduction to how to delete a page of content in Word Introduction to how to delete a page of content in Word Mar 26, 2024 am 10:06 AM

Title: Introduction to how to delete a page of content in Word When editing a document using Microsoft Word, you may sometimes encounter a situation where you need to delete the content of a certain page. You may want to delete a blank page or unnecessary content on a certain page in the document. In response to this situation, we can take some methods to quickly and effectively delete a page of content. Next, some methods to delete a page of content in Microsoft Word will be introduced. Method 1: Delete a page of content First, open the Word document that needs to be edited. Certainly

See all articles