2009-02-28 18 views
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); 

Antwort

0

Bevor ich Ihre Frage beantworten können, bitte angeben, was hier vor sich geht:

$('#ccam').append(img).append(html); 

Was im img var ist und was in der html var?

Verwandte Themen