Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > AJAX and character

Reply
Thread Tools

AJAX and character

 
 
servandomontero@gmail.com
Guest
Posts: n/a
 
      02-01-2007
I have a simple AJAX script that sends and retrieves a text file. The
ajax function is called from index.html

....
var obj = document.getElementById(objID);

xmlHttp.open("GET", "testing.txt", true);
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
obj.innerHTML = xmlHttp.responseText;
}
}

xmlHttp.send(null);
....

The script works OK. I can see the 'testing.txt' file just fine. The
issue is that the file (testing.txt) contains spanish character like:
í, á

and i see this ? instead of those spanish characters.

This is my syntax in my index.html:
....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
....


What's wrong?

Is this a server issue? Coz' i'm hosting with Yahoo and i dont have
access to change the configuration of the server, obviously.

Please Help
sm

 
Reply With Quote
 
 
 
 
Daz
Guest
Posts: n/a
 
      02-01-2007
On Feb 1, 8:01 pm, "servandomont...@gmail.com"
<servandomont...@gmail.com> wrote:
> I have a simple AJAX script that sends and retrieves a text file. The
> ajax function is called from index.html
>
> ...
> var obj = document.getElementById(objID);
>
> xmlHttp.open("GET", "testing.txt", true);
> xmlHttp.onreadystatechange = function()
> {
> if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
> {
> obj.innerHTML = xmlHttp.responseText;
> }
> }
>
> xmlHttp.send(null);
> ...
>
> The script works OK. I can see the 'testing.txt' file just fine. The
> issue is that the file (testing.txt) contains spanish character like:
> í, á
>
> and i see this ? instead of those spanish characters.
>
> This is my syntax in my index.html:
> ...
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>Sample 2_1</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1" />
> ...
>
> What's wrong?
>
> Is this a server issue? Coz' i'm hosting with Yahoo and i dont have
> access to change the configuration of the server, obviously.
>
> Please Help
> sm



The problem is that the server is not setting the header for the
returned data, so it's not processed correctly when it gets to the
client.

THis article should help you figure out how to solve the problem:
http://www.taylanpince.com/blog/AJAX...r-Support.html

 
Reply With Quote
 
 
 
 
SM
Guest
Posts: n/a
 
      02-01-2007
Thanks Daz for your answer. Basically what your saying is to use PHP
script instead of a txt file. Got it!
I will try it.

Thanks
sm

On Feb 1, 3:14 pm, "Daz" <cutenfu...@gmail.com> wrote:
> On Feb 1, 8:01 pm, "servandomont...@gmail.com"
>
>
>
> <servandomont...@gmail.com> wrote:
> > I have a simple AJAX script that sends and retrieves a text file. The
> > ajax function is called from index.html

>
> > ...
> > var obj = document.getElementById(objID);

>
> > xmlHttp.open("GET", "testing.txt", true);
> > xmlHttp.onreadystatechange = function()
> > {
> > if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
> > {
> > obj.innerHTML = xmlHttp.responseText;
> > }
> > }

>
> > xmlHttp.send(null);
> > ...

>
> > The script works OK. I can see the 'testing.txt' file just fine. The
> > issue is that the file (testing.txt) contains spanish character like:
> > í, á

>
> > and i see this ? instead of those spanish characters.

>
> > This is my syntax in my index.html:
> > ...
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html>
> > <html xmlns="http://www.w3.org/1999/xhtml">
> > <head>
> > <title>Sample 2_1</title>
> > <meta http-equiv="Content-Type" content="text/html;
> > charset=iso-8859-1" />
> > ...

>
> > What's wrong?

>
> > Is this a server issue? Coz' i'm hosting with Yahoo and i dont have
> > access to change the configuration of the server, obviously.

>
> > Please Help
> > sm

>
> The problem is that the server is not setting the header for the
> returned data, so it's not processed correctly when it gets to the
> client.
>
> THis article should help you figure out how to solve the problem:http://www.taylanpince.com/blog/AJAX...racter-Support....



 
Reply With Quote
 
Daz
Guest
Posts: n/a
 
      02-02-2007
On Feb 1, 8:50 pm, "SM" <servandomont...@gmail.com> wrote:
> Thanks Daz for your answer. Basically what your saying is to use PHP
> script instead of a txt file. Got it!
> I will try it.
>
> Thanks
> sm
>
> On Feb 1, 3:14 pm, "Daz" <cutenfu...@gmail.com> wrote:
>
> > On Feb 1, 8:01 pm, "servandomont...@gmail.com"

>
> > <servandomont...@gmail.com> wrote:
> > > I have a simple AJAX script that sends and retrieves a text file. The
> > > ajax function is called from index.html

>
> > > ...
> > > var obj = document.getElementById(objID);

>
> > > xmlHttp.open("GET", "testing.txt", true);
> > > xmlHttp.onreadystatechange = function()
> > > {
> > > if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
> > > {
> > > obj.innerHTML = xmlHttp.responseText;
> > > }
> > > }

>
> > > xmlHttp.send(null);
> > > ...

>
> > > The script works OK. I can see the 'testing.txt' file just fine. The
> > > issue is that the file (testing.txt) contains spanish character like:
> > > í, á

>
> > > and i see this ? instead of those spanish characters.

>
> > > This is my syntax in my index.html:
> > > ...
> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > > <html>
> > > <html xmlns="http://www.w3.org/1999/xhtml">
> > > <head>
> > > <title>Sample 2_1</title>
> > > <meta http-equiv="Content-Type" content="text/html;
> > > charset=iso-8859-1" />
> > > ...

>
> > > What's wrong?

>
> > > Is this a server issue? Coz' i'm hosting with Yahoo and i dont have
> > > access to change the configuration of the server, obviously.

>
> > > Please Help
> > > sm

>
> > The problem is that the server is not setting the header for the
> > returned data, so it's not processed correctly when it gets to the
> > client.

>
> > THis article should help you figure out how to solve the problem:http://www.taylanpince.com/blog/AJAX...racter-Support....


Not necessarily. I am just saying that you should use some kind of
script (be it ASP, PHP, Java, Perl, etc), to read the text file, and
set the header before sending it to the client.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UTF-8 Character Encodings and "NO-BREAK SPACE" (dec: 202, hex: CA)Character mrdecav@gmail.com HTML 7 02-01-2009 11:05 PM
get wide character and multibyte character value George2 C++ 2 01-25-2008 08:59 AM
check and convert lower character to upper character alessio211734@yahoo.it C++ 3 11-18-2007 11:28 AM
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM
getting the character code of a character in a string Velvet ASP .Net 9 01-19-2006 09:27 PM



Advertisments