0
이것은 내 코드입니다.창로드 기능이 제대로 작동하지 않습니까?
ui 요소를 채우는 데 window onload 함수를 사용했지만 제대로 작동하지 않습니다.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Regalo - Shop</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/bootstrap.min.css" />
<script src="<%=request.getContextPath()%>/resources/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(window).on('load',function(){
alert("OK");
<c:forEach var="item" items="${itemList}">
var name= '${item.desktopbrand}';
var details='${item.details}';
var id = '${item.desktopid}';
var price = '${item.desktopid}';
var catagory = '${item.catagory}';
var spanTag = '<div class="col-sm-6 col-md-4"> <div class="thumbnail"> <img data-src="img/Desktop/'+ id +'.jpg"> <div class="caption"><h3>'+ name+ '</h3> <p>'+ price+ '</div> </p> <p><button type="button" class="btn btn-success btn-lg" onclick="details()">Show Details</button></p><p><button type="button" class="btn btn-success btn-lg" onclick="addToCart()">Buy now</button></p></div></div></div>';
$("#" + catagory).append(spanTag);
</c:forEach>
});
</script>
</head>
<body>
<h1>Gens Cooner</h1>
<div id="gen" class="container"></div>
<h1>Ladies Cooner</h1>
<div id="lad" class="container"></div>
<h1>Childrens Cooner</h1>
<div id="chil" class="container"></div>
</body>
</html>
문제점을 찾으려고 시도했지만 시도 할 수 없습니다. 귀하의 도움을 높이 평가 될 것입니다.
서버 측 코드를 보면 자바 스크립트를 디버깅하려고하지 마십시오 페이지에 하나의 온로드 기능을 사용할 수 있습니다. – Quentin
서버 사이드 코드가 출력하는 JavaScript를보십시오. 왜 작동하지 않는지 확인하십시오. 그런 다음 바로 수정하거나 서버 측 코드가 왜 사용자가 생각하는 출력을 제공하지 않는지를 결정하십시오. – Quentin
일부 자바 스크립트가 아닌 HTML 컨텐츠를 생성하기 위해 서버 측 코드를 사용하지 않는 특별한 이유가 있습니까? –