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 8398361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:02:17+00:00 2026-06-09T21:02:17+00:00

I have array of ids like the follows: var arr = [1, 23, 6];

  • 0

I have array of ids like the follows:

var arr = [1, 23, 6];

I need to send this array to a server, parse it, and remove the ids from a mongoose db. For my backend I’m using nodejs express. So I need your advise how should I send the array by using jQuery and how should I parse it on a server.

  • 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-06-09T21:02:19+00:00Added an answer on June 9, 2026 at 9:02 pm

    Ok, follow this instructions and you are good:

    first of all, lets create our node server, I’m using the Express module to define the HTTP server:

    var fs = require('fs'),
        express = require('express'),
        app = express();
    
    
    app.listen(8080);
    
    app.use(express.bodyParser());
    
    app.get('/', function(req, res){
        var html = fs.readFileSync('index.html');
        res.header("Content-Type", "text/html");
        res.send(html);
    });
    
    app.post('/deleteIds', function(req, res){
        console.log(req.body.arr[0]);
        res.json({ success: true });
    });
    

    The server ‘/’ request returns an HTML page that will create an jQuery Ajax request, Here is the HTML file content:

    <html>
    <head>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
        <script type="text/javascript">
    
            $.ajax({
                url: 'http://localhost:8080/deleteIds',
                type: 'POST',
                data: {
                    arr: [ 1, 2, 3]
                },
                success: function(data){
                    console.log(data);
                }
            });
    
        </script>
    
    </head>
    <body>
    </body>
    </html>
    

    As you can see, the Ajax request in the html file sent as a POST request with an array as the data, The /deleteIds express path POST function in the server listens to that and takes the array using req.body.arr, note that I’m using app.use(express.bodyParser());, without this line we will not be able to get the body content from the POST request.

    This is it.. I hope this is helping understand Node + Ajax requests using express, from this point you can run on the arr and do what you want with the data.

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

Sidebar

Related Questions

I have an array of apps with ids and categories like this: [apps] =>
I have an array with a series of event IDs organized like this: $event['year']['month']['day']
I have array of products IDs. I have to make query like this: SELECT
I have an array with different IDs going from 1 to 4000. I need
I have a javascript array written like this... var json = [ {id:1, title:Test
I have an array of products IDs and I need to find the IDs
I have an array of ids like 127415157,31323794... (range not known). What is the
When I have array of ids, like ids = [2,3,5] and I perform Comment.find(ids)
I have one array, which are IDs from one ActiveRecord table. so I would
If i have an array with hundreds of random ids (having values too) like

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.