Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    Exclamation problem in ajax unicode

    hello guys,

    i am php developer

    there are problem with me in data unicode retrieved by ajax

    it is supposed to when i click on option in select menu , the table with red circle appear and get data from database

    the problem is that data appears as in the picture
    like that �������


    this is my function i use it :-

    function show_teams(id) {
    if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    document.getElementById("table_teams").innerHTML = xmlhttp.responseText;

    xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=ANSI;');


    the data is with arabic language

    can u help me plz ??

    i see problem like my problem in this forum

    here : http://www.codingforums.com/showthread.php?t=141067

    but i don't understand how he solved it ?!!!

    please help me quickly because this problem is very urgent in my work

    thank u very much and forgive me for my bad language
    Last edited by mido1987; 11-14-2011 at 01:12 PM.

  2. #2
    Senior Coder
    Join Date
    Dec 2010
    Thanked 570 Times in 563 Posts
    And you don't see any problem with this line?

    xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=ANSI;');
    Try charset=UTF-8 instead

    Generally speaking, you should do the following when using AJAX in conjunction with PHP/MySQL for example:

    1. Is the database encoding set to UTF-8?
    2. Do you use UTF-8 for the PHP/database connection? (like "set names 'utf8'")
    3. Do you use Javascript's encodeURIComponent() when sending data to the server?
    4. If you use special characters in plain text (like Javascript source files): Does this source use UTF-8 encoding? Check your editor!
    5. Do you set the Request-Header to UTF-8 (see above)?
    6. Do you have a meta tag in your HTML setting the charset to UTF-8?
    7. Do you set an output header from your PHP files to UTF-8? (header("Content-Type: text/html; charset=utf-8"); )


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts