SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2006
    Location
    Port Angeles, WA / currently Piestany, Slovakia
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question lightbox + prototype + Ajax.Request + Content-type = mangled diacritics?

    Hey everyone,

    I'm using a lightbox to display content fetched using Prototype's Ajax.Request. What the lightbox does is it essentially just document.writes a <div> with z-index:1000 (so it "floats above the page"). This works just fine however not when there's any diacritics (accent marks like ľ, , č, ť, , , , , , ř, ě, you get the idea) in the document that's being fetched through Ajax.Request. It still works but the accent marks aren't displayed correctly, there's just a "?" (question mark) instead of the letter. The parent document has a <meta http-equiv="Content-type" content="text/html; charset=windows-1250"> set and all the diacritics contained directly in this document do appear correctly. The problem occurs only with the content fetched from the server through Ajax.Request.

    I would post the code yet I don't believe the code is really the issue. It may be the document encoding, or the server's transfer encoding or something like that.

    Should anyone be able to help, I'd greatly appreciate it for I'm quite lost and I haven't been able to find a single relevant hit on Google...

    Files are hosted on a Linux server running Apache 2 + PHP 5.

    Resources:
    lightbox.js: http://particletree.com/features/lightbox-gone-wild/
    prototype.js: http://www.prototypejs.org/


    Best regards,
    Tom Kacmary

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XmlHttpRequest defaults to send content as UTF-8. You should set your server side script up to accept requests as UTF-8, and likewise serve data as UTF-8. Make sure that the server sends the correct Content-Type headers too, since <meta http-equiv /> can't be used in a non-html response.

  3. #3
    SitePoint Member
    Join Date
    May 2006
    Location
    Port Angeles, WA / currently Piestany, Slovakia
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks very much, kyberfabrikken, you have helped me a great deal. Now I just need to prepend
    PHP Code:
    <?php header('Content-Type: text/html; charset=UTF-8'); ?>
    to the content that is to be fetched through Ajax.Request and it seems to solve the problem.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •