jQuery의 초보자 인 Rzetterberg가이 게시물 webcam image refresh with ajax에서 확인해 보았 듯이 jQuery For Designer (J4D)에서 자습서를 읽었습니다.jQuery는 IPCam의 jpeg 이미지를 가져옵니다.
내 로컬 IP 카메라에서 가져 오는 이미지는 올바르게 표시되지만 기능을 새로로드 할 때마다 새로 가져온 이미지가 이전에 가져온 이미지 아래에 배치됩니다. 결과적으로 각 가져온 이미지가 서로 아래에 배치되는 페이지가 표시됩니다.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
var refreshId = setInterval(function() {
url = 'http://xxx.xxx.xxx.xxx?randval=';
var randval = Math.random();
var img = new Image();
$(img).load(function() {
$(this).hide();
$('#ipcam').removeClass('loading').append(this);
$(this).show();
}).error(function() {
// notify the user that the image could not be loaded
}).attr('src', url + randval);
}, 1000);
$.ajaxSetup({ cache: false });
});
</script>
</head>
<body id="page">
<div id="ipcam" class="loading">
</div>
</body>
</html>
누구든지 "ipcam"이라는 div 컨테이너에 새로운 가져온 이미지를 배치해야한다는 것을 알고 있습니까?
문제가 없으므로 devnull69의 대답에 동의 함을 표시하십시오. – dgvid