Linked Questions

Popular Questions

Problem with sending Arabic language using ajax

Asked by At

I'm using this example https://www.w3schools.com/php/php_ajax_php.asp to get the suggested words, it works fine with english words, but when i type in Arabic language i note that the $q = $_REQUEST["q"] is giving unknown characters when i var_dump($q), this problem is happening when i use Internet Explorer on windows 10 but with Google Chrome, everything is good.

I guess the problem is related to utf8 in Ajax code that internet explorer couldn't recognize Arabic characters, but i don't know how to modify it.

function showHint(str) {
if (str.length == 0) { 
    document.getElementById("txtHint").innerHTML = "";
    return;
} else {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {

        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("txtHint").innerHTML = 
   this.responseText;
        }
    };

    xmlhttp.open("GET", "gethint.php?q=" + str, true);
    xmlhttp.send();
}
}  

Any help please!

Related Questions