jquery 请求apache solr 跨域解决方案

仅作记录

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>apache solr get poi</title>
	<script type="text/javascript" src="js/jquery-1.4.min.js"></script>
    <script type="text/javascript">
	$(function(){
		//1.getJSON 方式
		$.getJSON("http://192.168.20.33:82/solr/select/?indent=on&version=2.2&q=*:*&start=0&rows=1&wt=json&sfield=store&pt=30.66,104.063&sort=geodist()%20asc&json.wrf=?", function(data){
			alert(data.response.docs[0].name);
		});
		//2.ajax 方式
		$.ajax({
			 'url': 'http://192.168.20.33:82/solr/select/?indent=on&version=2.2&q=*:*&start=0&rows=1&wt=json&sfield=store&pt=30.66,104.063&sort=geodist()%20asc',
			 //'data': {'wt':'json', 'q':'your search goes here'},
			 'success': function(data) { 
				alert(data.response.docs[0].name);
				console.log(data);
			 },
			 'dataType': 'jsonp',
			 'jsonp': 'json.wrf'
		});
		
	});
    </script>
  </head>
  <body >
  </body>
</html>


 

你可能感兴趣的:(jquery)