Solr 4.7-JSONP服务调用

Solr 4.7 - JSONP service call

本文关键字:调用 服务 7-JSONP Solr      更新时间:2023-09-26

试图从不同的域访问Solr JSON服务,我在chrome控制台窗口中使用了以下代码

$.ajax({
      dataType: "jsonp",
      url: 'http://localhost:8983/solr/select/?rows=5&start=0&q=nazeel&hl=true&wt=json&callback=?',
      success: function(result){console.log(result);}
    });

响应

Resource interpreted as Script but transferred with MIME type text/plain: "http://localhost:8983/solr/select/?rows=5&start=0&q=nazeel&hl=true&wt=json&callback=jQuery111003645529532805085_1398253785921&_=1398253785927". jquery.min.js:4
Uncaught SyntaxError: Unexpected token : 

JSON服务是有效的,正如我从一些域浏览器测试的那样

我正在寻找解决方案,找到了类似于将服务器响应从text/plain更改为text/javascript的答案。——有人能帮我改变这个或任何其他解决方案吗?

以下文章帮助了我,

http://skipperkongen.dk/2011/01/11/solr-with-jsonp-with-jquery/

我像一样格式化代码

$.ajax({
  'url': 'http://localhost:8983/solr/select/',
  'data': {'wt':'json', 'q':'nazeel','hl':true,'rows':5},
  'success': function(data) { console.log(data)},
  'dataType': 'jsonp',
  'jsonp': 'json.wrf'
});

现在它工作了!,希望这能帮助到别人。