<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>Basic</title>
	<!-- jQuery -->
	<link rel="stylesheet" href="<c:url value='/css/jqueryui.css'/>"/>
	<script src="<c:url value='/js/jquery.js'/>"></script>
	<script src="<c:url value='/js/jqueryui.js'/>"></script>
	
<script type="text/javascript">
$(document).ready(function(){
	// TODO [Step 2-1-3] 검색어에 대한 jquery ajax 자동완성 구현하기 
    $("#keyword").autocomplete({
      source: function(request, response){
    	   $.ajax({
    		  url:"<c:url value='/autoComplete.do'/>",
    		  contentType: "application/x-www-form-urlencoded; charset=UTF-8",//
    		  data: {'keyword' : encodeURIComponent(request.term)}, //after the input event
    		  dataType:'json',
    		  success: function(returnData, status){	  
    			response(returnData.resultList);
    		  }
    	  }); 
      },
      minLength : 1,
      select: function(event, ui){
    	    $("#keyword").val(this.value);
      }
    });
    
 
});
	
</script>
</head>
<body>
<form name="search">
<input type="text" name="keyword" id="keyword" />


</form>

</body>
</html>