Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Dynamic Ajax Content Chars being replaced

  1. #1
    Join Date
    Jul 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic Ajax Content Chars being replaced

    Dynamic Ajax Content

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    Charactures being replaced.

    Hi First thank's for all of the great scripts.

    I'm using the dynamic content script and have a strange problem. The script does it's job of pulling content in but the resulting content if it includes a £ characture is replaced by a ? .

    This is the page being pulled in http://www.hdweb.co.uk/kkpa/pages/content-about.html

    notice the last char is a £.

    And here is the page it's being pulled into
    http://www.hdweb.co.uk/kkpa/
    Click on the About Us button.

    The last char is now displayed as a ?

    I'm using the same headers for both the target and content pages as below

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    Any ideas?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Try:

    &#xa3;

    instead of:

    £
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks John, yep can do this but the content page is editable by our client so they should be able to just type in £

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You're not from the states are you? I am, and I cannot just type in that character. The problem is that although you may have a keyboard mapped to produce that character and a key on that keyboard that has the symbol of that character on it, it is still (in the language of computers) a non-standard character. So, on the web, unless the page is served with the proper encoding, that character will not survive the trip from the server to the user's screen. When you add to this another layer to the process, as is done with dynamically added ajax content, things must go very well for the character to survive. As currently written, the ajax content scripts at Dynamic Drive make no provision for passing the dynamic content's Content-Type meta data to the server during the XMLHttpRequest process and in fact, this may not be possible. If it can be done, I am not aware of how to go about it. The server itself may be able to be configured to this.

    Incidentally, you have another more serious problem with your example page. You have it coded to load into a division with the id of:

    main_Content

    but the id of that division is actually:

    Main_Content

    IE ignores this discrepancy and still finds the division in question. However, few if any other browsers will.
    Last edited by jscheuer1; 07-21-2006 at 06:59 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    &pound; is easier to remember.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jul 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks all so far for your replys.

    Does anyone ahve the code I could use to convert a £ symbol read from the content page to &pound; when the page is viewed in Main_Content.

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    In PHP:
    Code:
    $str = htmlentities($str);
    You should be doing this anyway, but evidently aren't. I suggest you use this.

    If for some reason you can't, you'll have to do it in Javascript:
    Code:
    str = str.replace(/&#163;/g, "&pound;");
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Jul 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Twey,

    Thanks. I'm obviously being a bit thick here

    Where exactly would i put the code?

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Find:
    Code:
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText.replace(/&#163;/g, '&pound;');
    }
    Add the bit in red.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Jul 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Twey. Really appcreciate your help here.

    extract from my page.

    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText.replace(/£/g, '&pound;');

    }



    However have added the code as suggested which all makes sense to me and I see how this should work ... But it has no effect, the £ is still displayed as ?


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
  •