7022

jquery remove strange characters from the array

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.

Recommend

  • Hive join to get the date wise picture
  • Why do emails not load images directly
  • PHP convert flat to nested multidimensional array in foreach loop
  • CosmosDB - SubDocument Delselecting - LINQ Query
  • MEAN stack ng-upload-file
  • Query not returning results as expected
  • EntityFramework Query Returns the same object for relationship
  • Submission of new app with iAds
  • Invalid object name 'dbo.Item'
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Query to find the duplicates between the name and number in table
  • Excel's Macro-Recorder usage
  • What and where is mdimport
  • zope_i18n_compile_mo_files doesn't work on a Zeo configuration
  • How do I get HTML corresponding to current DOM tree?
  • PHP buffered output depending on server setting?
  • Why does access(2) check for real and not effective UID?
  • Is it possible to access block's scope in method?
  • Meteor helpers not available in Angular template
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Modifying destination and filename of gulp-svg-sprite
  • ILMerge & Keep Assembly Name
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • GridView Sorting works once only
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • bootstrap to use multiple ng-app
  • Comma separated Values
  • How to get icons for entities from eclipse?
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • How to load view controller without button in storyboard?