Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Spanish characters and AJAX?

special characters in AJAX

6:55 pm on Oct 6, 2006 (gmt 0)

New User

10+ Year Member

joined:June 2, 2006
votes: 0

I have an AJAX script that displays the response provided by a PHP script that takes values from a MySQL database. It works fine with the English language, but text containing Spanish characters such as accented letters does not display properly. I am a javascript/ajax neophyte who has spent hours trying everything I can find on the internet to fix the problem to no avail. Could anyone tell me how I could change this AJAX script to make it work properly with Spanish language characters? Any help is greatly appreciated.
function loadurl(dest) {

try {
// Moz supports XMLHttpRequest. IE uses ActiveX.
// browser detction is bad. object detection works for any browser
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// browser doesn't support ajax. handle however you want

// the xmlhttp object triggers an event everytime the status changes
// triggered() function handles the events
xmlhttp.onreadystatechange = triggered;

// open takes in the HTTP method and url.
xmlhttp.open("GET", dest);

// send the request. if this is a POST request we would have
// sent post variables: send("name=aleem&gender=male)
// Moz is fine with just send(); but
// IE expects a value here, hence we do send(null);

function triggered() {
// if the readyState code is 4 (Completed)
// and http status is 200 (OK) we go ahead and get the responseText
// other readyState codes:
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
// xmlhttp.responseText object contains the response.
document.getElementById("output").innerHTML = xmlhttp.responseText;

I display the output like this:

<!--Loaded files go in Div below -->
<div id="output">

<!--End of loaded file Div -->

5:14 am on Oct 8, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
votes: 0

How do Spanish characters display? And, these should probably be converted to applicable HTML Entities on the server side prior to responding to your script.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members