jquery 请求apache solr 跨域解决方案

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
    var url = "http://172.21.0.31:13131/solr/xml/select?q=*%3A*&wt=json&indent=true";
    $(function(){
        //1.getJSON 方式
        $.getJSON(url+"&json.wrf=?", function(data){
            console.log(JSON.stringify(data));
        });
        
        //2.ajax 方式
        $.ajax({
             'url': url,
             //'data': {'wt':'json', 'q':'your search goes here'},
             'success': function(data) { 
                 console.log(JSON.stringify(data));
             },
             error : function() {
                  alert('1');
             },
             'dataType': 'jsonp',
             'jsonp': 'json.wrf'
        });
    });
    </script>

 

posted @ 2014-10-15 14:54  勿妄  阅读(585)  评论(0编辑  收藏  举报