Link to home
Start Free TrialLog in
Avatar of Jacobbaby
Jacobbaby

asked on

AJAX response character issue

Hello

       I have problem with french character  in AJAX response. When I fetch the result using ajax the response looks like ¿a marche d¿j¿?  . But without ajax it shows the original data as ça marche déjà? . How can I solve the issue?
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

It looks like a character set issue. Are you encoding the the string in PHP before returning it via AJAX? Look at http://www.php.net/htmlentities and pass your string through it before returning it. That way it will be (hopefully) character set independent.
Avatar of Jacobbaby
Jacobbaby

ASKER

It is partially working.  When I use htmlentities, it shows all the html elements in the data. Suppose my data is "<div class="test">ça marche déjà?</div>"  , I want to show only " ça marche déjà? ".
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok thank you
@Jacobbaby: It appears that you do not understand the grading guidelines for Experts-Exchange.  Please see the grading guidelines here:
http://support.experts-exchange.com/customer/portal/articles/481419
The asker must justify giving a C grade and give the experts an opportunity to improve it.
So why did you give this grade?

Upon looking at your profile, I see that out of the last dozen questions you've closed, you have deleted 5, and given 3 grades of "C", which is the worst possible grade you can give your colleagues at EE, where the "default" grade is "A" and your only real option is to mark the grade down to punish sloppy or uncooperative members.

I had not seen your post showing the HTML and the part about HTMLEntities(), but that, as you see, is not really the answer.  The appropriate use of HTMLEntities() would be determined by what you want to send to the browser.  If you want to send the HTML for use as markup, you would not use HTMLEntities().  If the data is from an external (tainted) source you would use strip_tags() to remove the HTML and/or HTMLEntities() to display the HTML.   Neither approach will have anything to do with the character set collision.