jQuery从数组中删除奇怪的字符 [英] jquery remove strange characters from the array
本文介绍了jQuery从数组中删除奇怪的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组,并将其发送到Web服务,
I have an array and I am sending it to a web service,
URL是这个
http://localhost:4025/vmp_webservice.asmx/LoadService2Daily?fromDate=2014-05-26+00%3A00%3A00&toDate=2014-05-26+23%3A59%3A01&campaigns%5B%5D=default&campaigns%5B%5D=Support
该网址无效,并返回500个内部错误
that url doesn't work and return 500 internal error
但是当我删除%5B%5D
时,URL变为:
but when I remove the %5B%5D
, the url becomes this:
http://localhost:4025/vmp_webservice.asmx/LoadService2Daily?fromDate=2014-05-25+00%3A00%3A00&toDate=2014-05-25+23%3A59%3A01&campaigns=default&campaigns=Support
它运行完美.
这些奇怪的字符是什么?如何删除它们?
what are these strange characters and how to remove them please?
数组是selectedCampains
,我这样发送:
$.getJSON(webServiceUrl,
{ fromDate: valFrom, toDate: valTo, campaigns: selectedCampaigns })
我以这种方式获得该数组:
I get that array in this way:
var selectedCampaigns = $("#campaignDiv input:checkbox:checked").map(function () {
return $(this).val();
}).get();
console.log(selectedCampaigns);
推荐答案
好的,这些是方括号,必须将其解析并从URL中删除:
OK, these are the square brackets and it has to parsed and removed from URL:
var sc = JSON.stringify(selectedCampaigns);
在尝试将selectedCampaigns
作为数组传递的地方传递此sc.
pass this sc where you're trying to pass selectedCampaigns
as an array.
这篇关于jQuery从数组中删除奇怪的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文