0
Ich versuche eine Update-Funktion für eine Webcam zu erstellen. Was es bisher macht, ist einen Ajax-Ruf zu machen und der Url des Bildes zu dienen. Ich habe ein Problem beim Binden des Ergebnisses (nachdem das Bild geladen wurde) an das dom-Element (ccam).Ein Bild an ein dom-Element binden
function update() {
$('#loading').show('fast');
$.ajax({
type: 'POST',
url: 'cam.php',
data: 'img=<? echo $cam_id; ?>',
timeout: 2000,
cache: false,
success: function(data) {
window.setTimeout(update, 20000);
$('#currcam').hide();
$('#daycam').show();
$('#loading').hide('fast');
$('#ccam')
.append(img)
.append(html);
// now show the image
$(img).fadeIn();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#loading").html('Timeout contacting server..');
window.setTimeout(update, 60000);
}
});
}
$(document).ready(update);