我有以下数组: var idParam = ["1","2","3"]; 我想使用jQuery.ajax将此数据作为请求发送,我正在做什么: $.ajax({ type: "GET", url: "Services/GetInfo.ashx", data: { "id": idParam }, contentType: "application/text", dat
var idParam = ["1","2","3"];
我想使用jQuery.ajax将此数据作为请求发送,我正在做什么:
$.ajax({ type: "GET", url: "Services/GetInfo.ashx", data: { "id": idParam }, contentType: "application/text", dataType: "json", success: function(result) { ... }, error: function(XMLHttpRequest, textStatus, errorThrown) { ... } });
但结果我有以下丑陋的字符串:?id [] = 1& id [] = 2& id [] = 4(实际上它更加丑陋:id [] = 1& id [] = 2& id [] = 4).
怎么做才能得到正常的字符串:id = 1& id = 2& id = 4 ??
谢谢
$.ajax()
的true参数
或者您可以在全球范围内进行设置:(from $.param()
docs)
As of jQuery 1.4, the
$.param()
method serializes deep objects recursively to accommodate modern scripting languages and frameworks such as PHP and Ruby on Rails. You can disable this functionality globally by settingjQuery.ajaxSettings.traditional = true;
.