将[] 添加到您网址中的键中:
$.getJSON("http://myurl.com/search-ext.json&type[]=aaaaaa&type[]=bbbbbb&callback=?",
另外,我不知道你是不是故意这样做的,但至少看起来你需要一个 ? .json 之后:
$.getJSON("http://myurl.com/search-ext.json?type[]=aaaaaa&type[]=bbbbbb&callback=?",
然后,例如在 PHP 中,您将在服务器上有一个数组:
$_GET['type'] ~ array('aaaaaa','bbbbbb')
编辑
在其他 cmets 之后,我相信这就是您正在寻找的:
http://plugins.jquery.com/project/query-object
var newerQuery = $.query.SET('type', 'bbbbb');
var newURL = "http://myurl.com/search-ext.json?" + newerQuery;
$.getJSON(newURL);
一个例子:
http://jfcoder.com/test/gettypes.php?type=aaaaaa&callback=MyCallback
编辑 2
<a href="href://www.somewhere.com/?type=aaaaaa&other=yes&another=yes&yeti=neverseen"
onClick="return replaceType(this,'bbbbbb')">Link</a>
function replaceType(el, value) {
sub = el.href.substring(0,el.href.indexOf('?'));
split = el.href.substring(el.href.indexOf('?')+1).split("&");
for (var i = 0; i < split.length; i++) {
if (split[i].indexOf('type=') !== 0) continue;
split[i] = encodeURI("type="+value);
}
el.href = sub + "?" + split.join('&');
alert(el.href);
return false;
}
http://jsfiddle.net/Phjsv/1/