0
我正在尝试为摄像头设置更新功能。到目前为止,它做的是一个Ajax调用并为图像的Url服务。我有一些问题绑定结果(图像加载后)到DOM元素(ccam)。将图像绑定到dom元素
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);