Servus,
Also ich möchte per AJAX ein bild in ein div-tag laden. Jedoch, hol ich mir die URL des Bilder per $_GET also PHP, das heißt ich weiß nicht was das für ne Datei ist, das kann ebenso ne XML Datei oder sont irgendwas sein.
|
Javascript-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
window.onload = function () {
var url = '<?php echo $_GET['url']; ?>';
var req = new Ajax.Request( url,
{
//onComplete:showResponse,
onfailure:showError,
on404: showError404,
onLoading: showLoad,
onSuccess: showResponseFile
}
);
}
var showResponse = function(r) {
$('main').update ((r.responseXML) ? r.responseXML : r.responseText);
}
var showError = function(r) {
$('main').update (r.statusText);
}
var showError404 = function(r) {
$('main').update (r.statusText);
}
var showLoad = function (r) {
}
var showResponseFile = function (r) {
$('main').update(r.responseText);
}
|
PS: Ich nutze Prototype !
Wenn ich also zb
http://domain.de/index.php?url=test.png eingebe wird die grafik nicht angezeigt. Also klar war mir das schon, das die Grafik nur durch responseText nicht angezeigt werden kann, aber einen anderen Weg kenne ich nicht.
bitte hilfe !
mfg