javascript – 使用jQuery构建的查询字符串和重复键的AJAX调用

Apache Solr要求发送到其端点的GET参数之一是重复的名称
facet.range=price&facet.range=age

文档在这里

http://wiki.apache.org/solr/SimpleFacetParameters#facet.range

在jQuery中,如何将查询字符串参数(facet.range)包含两次?我不能用重复键创建一个对象,但这是我需要做的事情:

context = {
    'facet.range': 'price','facet.range': 'age',// This will be the only element in this dictionary as the key names are the same
}

$.ajax({
    type: "get",url: 'http://127.0.0.1:8983/solr/select',dataType:"jsonp",contentTypestring: 'application/json',jsonp:"json.wrf",data: context,success:function (data) {
        ...
    }
});

解决方法

在params对象中使用’facet.range’:[‘price’,’age’]并在ajax调用中将Traditional设置为true,以强制执行参数的“传统”序列化,即foo = 1& foo = 2 of foo [] = 1& foo [] = 2.

相关文章

IE6是一个非常老旧的网页浏览器,虽然现在很少人再使用它,但...
PHP中的count()函数是用来计算数组或容器中元素的个数。这个...
使用 AJAX(Asynchronous JavaScript and XML)技术可以在不...
Ajax(Asynchronous JavaScript and XML)是一种用于改进网页...
本文将介绍如何通过AJAX下载Excel文件流。通过AJAX,我们可以...
Ajax是一种用于客户端和服务器之间的异步通信技术。通过Ajax...