编码的问题在AJAX [英] Encoding Problem In AJAX

查看:137
本文介绍了编码的问题在AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建两个下拉列表中的一种形式。我已经产生了第一个下拉列表,从MySQL数据库。当我选择一个选项,从第一个下拉列表,我不得不产生第二个下拉列表中选择通过一个下拉从MySQL数据库列表中选择的值。我使用code从这个链接(AJAX)这样做

I'm trying to create two drop down list in a form. I have generated the first drop down list from MySQL database. When i select an option from first drop down list, i have to generate second drop down list options by the selected value of first drop down list from MySQL database. I did this by using the code from this link (AJAX)

http://www.w3schools.com/PHP/php_ajax_database.asp

我的问题,通过所谓的JavaScript的网页无法连接codeD。除了我使用的是阿拉伯语郎所以第二个下拉菜单的结果是没有意义的形状。

My problem that the page called by javascript can't be encoded. Besides I'm using the Arabic lang so the outcome of the second drop down menu is meaningless shapes.

我曾尝试不同的方法来解决这个问题喜欢用头(..),AJAX.get(..) 但没有一个人工作:(

I have tried different ways to solve the problem like using header(..),AJAX.get(..) but NO one works :(

我该如何解决这个问题呢?

how can i solve this problem?

在此先感谢! 问候, Manalkk

Thanks in Advance!! Regards, Manalkk

推荐答案

它根据在HTTP头中指定的字符集,直到跨preT浏览器。这要求您要发送的实际产量是继该编码。

The browser till interpret it based on the character set that you specify in the http headers. That requires that the actual output that you are sending is following that encoding.

通过你的设置必须满足以下条件:

With your setup the following must be true:

您必须获取该指定了正确的编码(SET名称编码)的连接上从MySQL中的所有数据,默认为拉丁文/ ISO-8859-1

You must fetch all data from mysql on a connection that is specified with the correct encoding (SET NAMES "encoding"), the default is latin1 / ISO-8859-1

PHP内部只能用拉丁文工作为好,但任何动态数据应该没问题,除非你不要做了很多字符串操作,那么你可能会遇到的问题。

PHP internally only work with latin1 as well, but any dynamic data should be okay unless you don't do a lot of string manipulation, then you might run into problem.

如果你的PHP页面的任何内容是静态的,必须保存在PHP页面中相应的字符集(例如,UTF-8)。

If any content in your php-page is static, you must save the php-page in the corresponding charset (for example, utf8).

PHP页面必须指定标题的内容类型:

The php page must specify content type in the header:

标题(内容类型:text / html的;字符集= UTF8); // 替换的实际内容类型和所使用的字符集。

header("Content-Type: text/html;charset=utf8"); //replace with the actual content type and charset you are using.

您数据库中的数据必须相应地存储,从已经指定的正确的编码的连接,否则数据库会做不正确​​的转换或从数据库。

Your data in the database must be stored accordingly, from a connection that has specified the correct encoding, otherwise the database will do incorrect conversion to or from the database.

这篇关于编码的问题在AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆