【问题标题】:Ajax call from js to solr for spatial search从 js 到 solr 的 Ajax 调用以进行空间搜索
【发布时间】:2015-05-03 19:43:20
【问题描述】:

我在这里做错了什么?我正在尝试通过 js ajax 调用从 solr 访问数据,这会导致错误。如何提供空间数据?

$.ajax({
    url: 'http://xxx:20000/solr/cvcorelm0/select',
    data: {
        'wt':"json", 
        'q':"*:* AND doctype:1", 
        'fq':"{!geofilt}",
        'spatial':true,
        'pt':28.314744,84.778104,
        'd':100},
        'success': function(data) {
            console.log(data);        
        },
        'error':function(data){
            console.log(data);
        },
        dataType: 'jsonp',
        jsonp: 'json.wrf'
    });

请帮忙

【问题讨论】:

  • 注意,代码中少了一个}

标签: javascript ajax json solr geospatial


【解决方案1】:

你最后错过了} data: {,应该是:

$.ajax({
    url: 'http://xxx:20000/solr/cvcorelm0/select',
    data: {
        'wt':"json", 
        'q':"*:* AND doctype:1", 
        'fq':"{!geofilt}",
        'spatial':true,
        'pt':28.314744,84.778104,
        'd':100},
        'success': function(data) {
            console.log(data);        
        },
        'error':function(data){
            console.log(data);
        },
        dataType: 'jsonp',
        jsonp: 'json.wrf'
    } // the missed } here.
});

【讨论】:

    【解决方案2】:
    var temp = 28.314744,84.778104;
    $.ajax({
        url: 'http://xxx:20000/solr/cvcorelm0/select',
        data: {
            'wt':"json", 
            'q':"*:* AND doctype:1", 
            'fq':"{!geofilt}",
            'spatial':true,
            'pt':temp,
            'd':100},                    //data { is closed here.
            'success': function(data) {
                console.log(data);        
            },
            'error':function(data){
                console.log(data);
            },
            dataType: 'jsonp',
            jsonp: 'json.wrf'
        });
    

    在将 28.314744,84.778104 分配给变量并在数据中提供时起作用。

    【讨论】:

      猜你喜欢
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2014-12-20
      • 1970-01-01
      相关资源
      最近更新 更多