tags:

views:

61

answers:

1

I am trying to make an update function for a webcam. What it does so far is make an ajax call and serve the Url of the image. I have some problem binding the result (after the image is loaded) to the dom element (ccam).

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);
A: 

Before I can answer yoru question, please specify what is going on here:

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

What is in the img var and what is in the html var?

Pim Jager