<%@ page language="java" import= "java.util.*" pageEncoding="UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type= "text/javascript" src="js/jquery-1.5.2.js" ></script>
<script>
$(document).ready( function() {
$( "#button1" ).click(function(){
var t=$("#text1" ).val();
str=encodeURI(t);
$.ajax({
url:'http://localhost:8080/solr/coretest/select/?q=sName:' +str+'&version=2.2&start=0&rows=10&indent=on&wt=json' ,
dataType: "json", //ajax返回值设置为text(json格式也可用它返回,可打印出结果,也可设置成json)
success: function(data){
result=data.response.docs;
for( i=0;i<result.length;i++ ){
alert(result[i].sName);//可以取到字段的值,弹出框显示“陈奕迅”
alert(result[i].sAge);
}
},
error: function(json){
return false;
}
});
});
});
</script >
</head>
<body>
<div id="div1">
<input type= "text" id ="text1" name="text1" /><input type= "button"
id= "button1" value ="搜索" />
</div >
<div id="div2"></ div>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------
说明:url里面的参数sName冒号是模糊查询的字符串,
version:版本
start:是结果集开始的位置
rows:设置每页显示的行数,indent
indent:
wt:
效果如下: