7022

Question:
I have an array and I am sending it to a web service,
the url is this
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
that url doesn't work and return 500 internal error
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
and it works perfectly.
what are these strange characters and how to remove them please?
The array is the selectedCampains
and I am sending it like this:
$.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);
Answer1:OK, these are the square brackets and it has to parsed and removed from URL:
var sc = JSON.stringify(selectedCampaigns);
pass this sc where you're trying to pass selectedCampaigns
as an array.