Ajax und Header("Content-Type")

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Ajax und Header("Content-Type")

    Hey vllt kennt hier jemand das Problem und hat die passende Lösung :P
    Per Ajax.Request (egal ob prototype oder jquery oder selbstgeschrieben) rufe ich die datei img.php auf. (img.php ist ein Captcha script)

    [Ich nehme jetzt einfach ein anders beispiel für die img.php aber es kommt das selbe bei raus.]

    also img.php

    Quellcode

    1. header ( 'Content-Type: image/png' );
    2. $image = imagecreate ( 300, 150 );
    3. $farbe_body = imagecolorallocate ( $image, 243, 243, 243 );
    4. imagepng ( $image );
    5. //einfaches bild mit grauem hintergrund


    Rufe ich img.php jetzt auf, alles super und es wird dargestellt ohne Probleme.

    Binde ich img.php jetzt in das Ajax.Request ein, und will mir das ergebnis in einem Div darstellen lassen, kommt nur noch sowas bei raus:

    Quellcode

    1. �PNG ��� IHDR���2���d����&����PLTE����[�˝������� @ZA�-�(>WA�����Q0���o�D=]&����IEND�B`�


    Gibt es eine Lösung für das Problem, dass es auch nach dem Ajax.Request dargestellt wird?


    EDIT://
    Achja das Ajax.Request =>

    Quellcode

    1. <script type="text/javascript">
    2. function foo(){
    3. new Ajax.Request("img.php", { onSuccess: function(transport) {
    4. var notice = $('notice');
    5. notice.update(xml_http.responseText);
    6. }
    7. });
    8. }
    9. </script>
    10. <a href="javascript:;" onclick="foo();">Cap</a>
    11. <div id="notice">Resultat</div>
    Alles anzeigen

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Snowflake ()