Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3341156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:41:26+00:00 2026-05-18T00:41:26+00:00

I have the need to send an array of ID’s to my server-side in

  • 0

I have the need to send an array of ID’s to my server-side in the form of a JSON Object.I am using a dropdownlist where multiple values can be selected to do an action with them.

To get them in an array, I’ve used:

var selectedArray = [];

            var selectObj = document.getElementById('addedList');
            var i=0;
            var count=0;
            for(i=0;i<selectObj.options.length;i++){
                selectedArray[count] = selectObj.options[i].value;
                count++;
            }

Now the question is, I need to get those ID’s to the server.
I’ve always thought of sending it like a JSON object, since it has a variable amount of parameters. As far as I found out, you can convert a JS object to JSON.

Now I do have a few questions:

Could you give me an example of how to convert it? There seem to be a million ways, one of them being JSON.stringify(jsObj);. My object would simply consist of an array of values. As far as I know this would be an example:

{ array : ["value1","value2","value3"] }

Another question is:
How can I send this using jQuery? Can I send a JSON object to the server using $.getJSON? (This uses $.GET under the hood), or do I need to use $.POST ?

Now I’ve just been trying, but can’t get it out…

$.getJSON code

        $.getJSON("removerequest.htm",{ ids: JSON.stringify(selectedArray) }, function(data){
            $('#removerequestdiv').text('');

            $('#removerequestdiv').append('<select name="addedList">');
            for(var index in data){
                $('#removerequestdiv').append('<option value="' + data[index].id + '">' + data[index].voornaam + data[index].familienaam + '</option>');
            }
            $('#removerequestdiv').append('</select>');
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:41:26+00:00Added an answer on May 18, 2026 at 12:41 am

    The $.getJSON() routine is for fetching JSON-encoded content from the server. Your problem is the opposite: you want to send it to the server.

    You should understand the terminology here. There’s no such thing really as a “JSON object” in Javascript. It’s just a Javascript object of some sort, and there’s nothing special about it in that sense. What you want to do is serialize the Javascript object into a single string. That string is your parameter you’ll send to the server, and the server will deserialize that string back into an object (in the context of whatever language your server code is using).

    Thus, when you call JSON.stringify(obj), what you get is just a string. Passing such a string back to the server is no different than passing any other string; it’s just a parameter. Use $.post() to post it, or you can even just stuff it into the value of a simple form input element and post a form the old-fashioned way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays and I need to send the array values to PHP.
I have an array in javascript that I need to join and send through
I need to send a request to a quote server. Each request should have
i have a simple contact us form and i need to send an email
I have an array of hashes in Javascript, which I need to send as
I have an array of float that I need to send over TCP/IP, the
I have a situation where i need to send commands to a running java
I have a slow connection that I need to send a PNG image over
I have a list that I need to send through a URL to a
i have a scenario where in i need to send an xml as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.