Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Ajax i obrazek generowany przez php
karbo
post 17.11.2008, 14:29:35
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (0%)
-----


  1. <script type="text/javascript" language="javascript">
  2.  
  3. var http_request = false;
  4. function makeRequest(url) {
  5.  
  6. http_request = false;
  7. if (http_request.overrideMimeType) {
  8. http_request.overrideMimeType('Content-Type: image/png');
  9. }
  10.  
  11. if (window.XMLHttpRequest) { // Mozilla, Safari,...
  12. http_request = new XMLHttpRequest();
  13. if (http_request.overrideMimeType) {
  14. http_request.overrideMimeType('text/xml');
  15. }
  16. } else if (window.ActiveXObject) { // IE
  17. try {
  18. http_request = new ActiveXObject("Msxml2.XMLHTTP");
  19. } catch (e) {
  20. try {
  21. http_request = new ActiveXObject("Microsoft.XMLHTTP");
  22. } catch (e) {}
  23. }
  24. }
  25.  
  26. if (!http_request) {
  27. alert('Poddaję się :( Nie mogę stworzyć instancji obiektu XMLHTTP');
  28. return false;
  29. }
  30. http_request.onreadystatechange = function() { alertContents(http_request); };
  31. http_request.open('GET', url, true);
  32. http_request.send(null);
  33.  
  34. }
  35.  
  36. function alertContents(http_request) {
  37.  
  38. if (http_request.readyState == 4) {
  39. if (http_request.status == 200) {
  40. document.getElementById("test").innerHTML = http_request.responseText;
  41. } else {
  42. alert('Wystąpił problem z zapytaniem.');
  43. }
  44. }
  45.  
  46. }
  47. style="cursor: pointer; text-decoration: underline"
  48. onclick="makeRequest('im.php')">
  49. Odpytaj
  50. </span>
  51. TU:<br>
  52. <div id="test">
  53.  
  54.  
  55. </div>

Mam taki kod. plik im.php to obrazek generowany przez php. Jednak przy wyświetlaniu jest tylko syf(�PNG  ��� IHDR���...)nie ma header. Macie jakieś sposoby na rozwiązanie problemu?


--------------------
  1. <?php
  2. exit();
  3. ?>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 02:31