|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ajax script encoding problem
Hello. I have the following problem. I have an ajax script that calls a php page. The problem is that results that appear in my page that calls the ajax script is that the greek characters are not shown properly (instead i get some ??). The php page that i call with ajax if i called it directly i can see it in the correct way. I think that the problem is in ajax.
I do sth like the following http.open("GET", myurl+"&rand="+myRand, true); //i believe that http must have an attribute for specific encoding but i cannot find which http.onreadystatechange = useHttp5; http.send(null); function useHttp5() { if (http.readyState == 4) { if(http.status == 200) { var mytext = http.responseText; //if i alert here mytext, it has wrong encoding document.getElementById('choices').innerHTML = mytext; document. getElementById('Dresults').innerHTML = ""; } } else { document. getElementById('choices').innerHTML = ""; document. getElementById('Dresults').innerHTML = ""; } } Thanks |
|
#2
|
||||
|
||||
|
First, you're not a noob, use CODE tags!
![]() Make sure the back-end script is providing UTF-8 characters and the browser is set to display UTF-8 characters. HTML meta tag Code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> PHP header() Code:
header('Content-type: text/html; charset="utf-8"',true);
Consider using htmlentities.
__________________
------------- vbrtrmn -------------- i think i'm missing some vowels here ------------------------------------ ---------- js.antinoc.net ---------- ------------------------------------ --- The Two Types of Programmers --- |
|
#3
|
|||
|
|||
|
Thanks. Problem solved. I had in my php script only the meta tag and not the header. It is ok now!
Last edited by vasilanthropos : May 10th, 2008 at 09:49 AM. |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Ajax script encoding problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|