The prototype object of the Datatable request parameter is missing

When attempting to make a datatable ajax request, I encountered an unexpected result on the server side. The console is logging the data as shown below:

[Object: null prototype] {
  draw: '1',
  'columns[0][data]': 'no',
  'columns[0][name]': '',
  'columns[0][searchable]': 'true',
  'columns[0][orderable]': 'true',
  'columns[0][search][value]': '',
  'columns[0][search][regex]': 'false',
  'columns[1][data]': 'projectName',
 ...
'search[value]': '',
  'search[regex]': 'false',
  projectName: ''
}

The client-side js function responsible for this behavior is outlined below:

function getSettingInfo() {
    $('#settingInfo').show();

    $('#settingInfo').DataTable({
        destroy: true,
        processing: true,
        serverSide: true,
        searching: false,
        ajax: {
            type: 'POST',
            url: '/setting/getSettingInfo',
            data: function(d) {
                d.projectName = '';
            }
        },
        iDisplayLength: 10,
        order: [[0, 'desc']],
        pagingType: 'simple_numbers',
        columnDefs: [
            { className: "dt-head-center", targets: [0, 1, 2, 3, 4] },
            { className: "dt-center", targets: [0, 1, 2, 3, 4] },
        ],
        columns: [
            { data : "no", width : '6%'},
            { data : "name", width : '13%'},
            { data : "key", width : '17%'},
            { data : "description", width : '32%'},
            { data : "use", width : '32%'}
        ]
    });
}

In addition, here is the server router's js code:

router.post('/getSettingInfo', async function (req, res) {
    let param = req.body;
    console.log('\n\nparam', param);
}

I am facing a dilemma where the request object is being interpreted as a null object. It is causing param.order in my last javascript file to be logged as undefined.

Answer №1

At last, I have discovered it.

In my app.js file

app.use(express.urlencoded({ extended: true }));

The use of 'extended: false' resulted in issues with the json.stringify ajax request. Therefore, I made the switch from false to true.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering a white screen while loading StaticQuery on Gatsby website

I encountered an error that has been reported in this GitHub issue: https://github.com/gatsbyjs/gatsby/issues/25920. It seems like the Gatsby team is currently occupied and unable to provide a solution, so I'm reaching out here for help. Just to clar ...

What am I doing wrong that causes me to repeatedly run into errors when trying to build my react app?

While attempting to set up a react.js web application in VScode using "npm," I encountered the following errors: npm ERR! code ERR_SOCKET_TIMEOUT npm ERR! errno ERR_SOCKET_TIMEOUT npm ERR! network Invalid response body while trying to fetch https://registr ...

Unable to invoke requestPointerLock() function within Vue.js component

Incorporating the requestPointerLock() method within a Vue.js component has posed some challenges for me. In the scenario where the pointerShouldLock data property of my component is set to true, I intend for the pointer to be locked during the beforeUpdat ...

Difficulty obtaining elements in Internet Explorer, however works fine in Chrome and Firefox

My <textarea> is set up like this: <textarea class="form-control notetext" id="{{this._id}}-notetext" name="notetext">{{this.text}}</textarea> I am using ajax to send data and load a partial webpage. After loading the content, I attemp ...

Convert the string to a time format of hours and minutes (hh:mm)

I am currently working with an input field that requires a time value to be entered. The format for the Time field is in hh:mm on the 24-hour clock format, such as 7:30, 11:45, 16:10, 19:11, or 22:43. <input id="szReminderTime" type="text" value="" max ...

jQuery blueimp File Uploader: Transferring multiple files to the server on Internet Explorer

After customizing the demo for my Rails application, I encountered an issue with the plugin in Internet Explorer. While it works smoothly on Chrome and Firefox, in IE (all versions) it fails to upload all but one file when multiple files are selected, and ...

When setting up a new nodejs/express project, I encountered an issue where the fresh installation would fail

After setting up node and express on my new development server, I created a test application by running the command below: dev-server15:/var/www# express mytest create : mytest create : mytest/package.json create : mytest/app.js ... The npm ...

The concept of dynamic schema in Mongoose allows for flexibility and

Currently, I am working on creating a product schema that involves setting pricing in different currencies. However, I am facing confusion regarding how to dynamically create currency options. The pricing may vary in one currency or multiple currencies as ...

Incorporating a fresh child data element using Razor Pages, AJAX, and Entity Framework Core

Having transitioned from ASP.NET WebForms, I find myself a bit overwhelmed. Currently, I am working on an ASP.NET Core Razor Page that retrieves an incident along with all its associated comments. While I have successfully implemented refreshing the commen ...

Attach a child element to the bottom of its parent div when the parent div reaches the bottom

I'm looking to make a child div stick to the bottom when the parent div reaches the bottom of the browser window. Note: This behavior should only occur when the parent div is pushed down, not when the page is scrolled down. For instance, in my demon ...

The issue I'm facing with my webpack-build is the exclusive appearance of the "error" that

Hey everyone! I'm currently facing an issue with importing a module called _module_name_ into my React project, specifically a TypeScript project named react-app. The module was actually developed by me and it's published on npm. When trying to i ...

The console is displaying a promise that is pending, rather than the desired data

Here is the content of my file: 'use strict' import * as moment from "moment"; import { Report} from "./Report"; import { Timeframe} from "./Timeframe"; import { ReportComparison } from "./ReportComparison"; function test(firstFrom: string, fi ...

Exploring the OAuth 2.0 integration with OpenID Connect, Loopback, and Keycloak

I'm having trouble establishing a connection to Keycloak from Loopback. I've been experimenting with the keycloak-connect library available at: https://github.com/keycloak/keycloak-nodejs-connect This snippet shows my current implementation in ...

Utilizing NodeJS application to connect to Sharepoint 2019 On-Premises Web Services

Recently, I/T in my organization set up a new Sharepoint 2019 OnPromise with a hybrid configuration that utilizes Azure AD for authentication. As the site collection admin for our Sharepoint website, the URL to access it is Upon accessing this URL, I am ...

"Utilizing three.js to smoothly move the camera forward with a left mouse click

I am currently working on a 3-D graphical website using three.js. The theme of the website is a universe filled with text. My goal is to make the camera move forward when the left mouse button is clicked and backward when the right mouse button is clicked. ...

Bypass the typical practice of choosing input with javascript

I have a form with a select input that has a dropdown list of options. The requirement is that when the select input is clicked, I need to validate the form. If the form is incomplete, I want to prevent the select input from showing the option list. Howeve ...

Having an issue with Jquery selector where the text does not match

HTML Code <select id="myDropdown"> <option selected="selected" value="0">default</option> <option value="1">bananas</option> <option value="2">pears</option> </select> Javascript Function setDr ...

Why are my variables resetting in Angular after ngAfterViewInit?

There seems to be an issue with my variables resetting after successfully using them in ngAfterViewInit(). I have a few @ViewChild and regular variables that are utilized or set in ngAfterViewInit. However, when certain events that I added post-initializa ...

The functionality of the dropdown does not seem to be working properly when the checkbox is

So, I have a simple task where if a checkbox is selected, a drop-down should appear. If the checkbox is unselected, the dropdown should not show up. However, it seems like there's an issue with my code. Here's a snippet below to give you an idea ...

Sinatra application encounters internal server error resulting in AJAX request failure

I'm currently developing a game where a user's guess is submitted to the backend for evaluation and then feedback is returned in the form of an array. To achieve this, I am utilizing AJAX to fetch a set of data from a Sinatra backend. Below is th ...