简体   繁体   English

语法错误:丢失; 声明前SOLR

[英]SyntaxError: missing ; before statement SOLR

I want to get data from a Solr server, using Angular (and put result in a table). 我想使用Angular从Solr服务器获取数据(并将结果放入表中)。

I wrote my Angular controller and I used $http. 我编写了Angular控制器,并使用了$ http。 Like this: 像这样:

var myApp_1 = angular.module('myApp_1', []);
myApp_1.controller('RequestCtrl', ['$scope', '$http', function ($scope,  $http){

$scope.title = {};
$scope.response = {};

var url = "http://10.1.1.1:8983/solr/testCore/select?q=*%3A*&wt=json&callback=jsonp_callback";

$http.jsonp(url)
    .success(function (data){
        console.log(data.response);
    }).error(function (data) {
        console.log('Error');
    });

}]);

But it gave me the console message: SyntaxError: missing ; 但是它给了我控制台信息: SyntaxError:missing; before statement. 声明前。 I saw that the error came from the shape of the server answer; 我看到错误来自服务器答案的形状; which is: 这是:

{"responseHeader":
    {"status":0,"QTime":1,"params":
    {"q":"*:*","callback":"jsonp_callback","wt":"json"}},
    "response":{"numFound":5,"start":0,"docs":[                                              
        {"id":"123456789",
         "title":["45e"],
         "_version_":1506864900238999552},
        {"id":"12",
         "title":["aeuirs"],
         "_version_":1506865190152437760}
]}}

(I indent it here because it was pretty illegible, but not to much because it is difficult with the StackO. editor). (我在这里缩进是因为它非常难以辨认,但因为在StackO编辑器中很难,所以缩水了很多)。

I can't write &wt=jsonp in my url (it doesn't work). 我无法在自己的网址中写&wt = jsonp(这不起作用)。

Firebug said me that the error is after the "responseHeader": apparently, it should be a ; Firebug对我说,该错误在“ responseHeader”之后:显然,它应该是; instead of a : 代替 :

Any idea ? 任何想法 ?

The correct argument name should be &json.wrf=callback (or whatever callback name you want/need - the important thing is json.wrf ). 正确的参数名称应为&json.wrf=callback (或您想要/需要的任何回调名称-重要的是json.wrf )。

JSON Specific Parameters JSON特定参数

json.wrf=function - adds a wrapper-function around the JSON response, useful in AJAX with dynamic script tags for specifying a JavaScript callback function. json.wrf = function-在JSON响应周围添加包装函数,在带有动态脚本标签的AJAX中非常有用,用于指定JavaScript回调函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM