Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-14-2011, 12:07 PM   PM User | #1
mido1987
New to the CF scene

 
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mido1987 is an unknown quantity at this point
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();
}else{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

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

xmlhttp.open("POST","<?=base_url()?>btola/admin_btola/show_teams/"+id,true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=ANSI;');
xmlhttp.send();


}


============================================================================
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 12:12 PM..
mido1987 is offline   Reply With Quote
Old 11-14-2011, 12:56 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
And you don't see any problem with this line?

Code:
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"); )
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:52 AM.


Advertisement
Log in to turn off these ads.