<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>搜索首页</title>
		<%@ include file="../../common/meta.jsp"%>
		<link rel="stylesheet" type="text/css" href="${ctx}/styles/main.css" />
		<script type="text/javascript" src="${ctx}/plugins/jquery/jquery-1.8.3.js"></script>
		
		<script type="text/javascript">
		    var URL = '${ctx}/utils/search!' ;
			$(function(){
				$("#search_btn").bind("keyup ",function(){
					query();
				});
			});
			function query(){
				var keyWords = $('#search_btn').val().trim();
				$.ajax({
					type : 'post',
					data : {keyWords : keyWords},
					url : URL+'seachKeyWords.action',
					dataType : 'json',
					error : function(XMLHttpRequest,textStatus,errorThrown){
					
					},
					success : function(data){
						$('.no_result').remove();
						$('.result').remove();
						if($(data).size()==0){
							$('ul.result_list').append('<span class="no_result">没有结果</span>');
						}else{
							$(data).each(function(i,n){
								var $obj = '<li class="result"><a target= "_top" href='+n.src+'><span>'+n.name+'</span></a></li>';
								$('ul.result_list').append($obj);
							});
						}
					}
				});

			};
		
		</script>
	</head>
		
	<body>
		<input id="search_btn" class="" placeholder="搜索..." type="text">
		<ul class="result_list"></ul>
	</body>
	
</html>