In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about IE browser and FF browser about the difference between Ajax transfer parameter value for Chinese, which may not be understood by many people. In order to let everyone know more, Xiaobian summarizes the following contents for everyone. I hope you can gain something according to this article.
The details are as follows:
Here, we mainly analyze the garbled code processing methods for different browsers in the process of Ajax passing Chinese parameters.
Ajax passed parameters for Chinese garbled, I encountered the situation is:
1. My database connection code is GB2312, latin1_swedish_ci
2. php file encoding format is UTF-8, browser display encoding is: UTF-8
3. My page is displayed in two ways:
1) The page loads automatically when it loads, and refreshes every second.
2) Click on the name of an extension group to obtain the corresponding member card information of the extension group.
4. For the first case:
Get session on control.php page:
Read the contents of the database:
line 53:
The copy code is as follows:
$grouparr[] = iconv("GB2312","UTF-8",$g[0]); //Database content is converted to UTF-8, so that Chinese on the page can be displayed normally
line106:
The copy code is as follows:
$_SESSION ['dispatchgroup '] = iconv("UTF-8","GB2312",$grouparr[0]);//Change the converted Chinese to GB2312, which is used to obtain the condition value of the query in dispatchinfo.php file, and obtain the GB2312 encoded value.
dispatchinfo.php: line 291
if($_SESSION['dispatchgroup']){ $groupaddressinfo = function_listaddressesbygroup($_SESSION['dispatchgroup'],1,$value,0,$_SESSION['dispatchexten'],$_SESSION['dispatchgrouppage']); //2013-5-17$groupaddressinfo = "listaddressesbygrouptype| 0| LocalExt| 1| 12| 1, 801, free,| 1, 802, not online,| 1, 803, free,| 1, 804, not online,|,,, 805, not online,,|,,, 806, not online,,|,,, 807, not online,,|,,, 808, not online,,|,,, 809, not online,,|,,, 810, not online,| 5, Restaurant,,811,10.1.6.189; Connect| 6,,,812,user2; disconnected|";}
In this case IE and FF can be displayed normally.
5. For the second case:
Click the name of "Branch Unit" to obtain the Chinese name of the clicked Branch Unit, and transfer it to dispatchinfo2.php file for processing through Ajax. Before modification, js clicks the Chinese name obtained after the event, and the alert is the normal value [format is UTF-8]. At this time, the content in the database is GB2312. In this case, an error will occur after iconv transcoding.
Because only for the first case, I'm going to transcode it.
The copy code is as follows:
$groupname = iconv("GB2312","UTF-8",$groupname);
At this point again coding errors will occur,
Solution:
JS asynchronous commit processing:
checkval(); var ajax = InitAjax();var url = "dispatchinfo2.php? "+arges;//2013-08-21 limx Chinese encoding problem url = encodeURI(encodeURI(url));ajax.open ('GET ',url,true);
dispatchinfo2.php
$groupname = urldecode($groupname);$groupname = iconv("utf-8","GB2312",$groupname);
The four-line code perfectly solves the problem of Chinese coding.
Because the AJAX data is sent in UTF-8 encoding, it needs to be encoded on the server side (my page here is encoded in GB2312, if it is UTF-8, there should be no problem in this step), so I have UTF-8 to GB2312 on the server side.
After reading the above, do you have any further understanding of the difference between IE browser and FF browser about Ajax passing parameter value of Chinese? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.