Leveraging the post method in Ajax along with a Perl script and passing parameters

I am struggling to utilize the POST method in XMLHTTPRequest by invoking a Perl script with parameters. Despite confirming the validity of these variables (uName, uProject, etc.), and verifying that write.pl functions properly when parameters are manually passed via the command line,
I am encountering an issue where the parameters show up as empty when they are passed. Assistance would be greatly appreciated.

request.open("POST", "/cgi-bin/write.pl", true);
var params = uName + " " + uProject + " " + uSVAC + " " + uEVAC + " " + uLevel;
alert(params);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send(params);

Answer №1

When separating parameters, remember to use an ampersand & instead of a space (" ") as specified in x-www-form-urlencoded format. Special characters within values should be encoded (such as space to %20 and ampersand to %26). Additionally, make sure to assign names to your parameters.

For example:

var data = 'name=' + userName + '&project=' + userProject + '&start=' + startDate +
 '&end=' + endDate + '&level=' + userLevel;

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

Sending numerous array values from datatables

I am currently working with datatables that allow for multiple selections. When I select 3 rows from top to bottom (as shown in this picture), the console.log returns this specific value for each row selected. The value that needs to be passed to the next ...

Toggle visibility of div based on current business hours, incorporating UTC time

UPDATE I have included a working JSFiddle link, although it appears to not be functioning correctly. https://jsfiddle.net/bill9000/yadk6sja/2/ original question: The code I currently have is designed to show/hide a div based on business hours. Is there a ...

Removing one element from an array with mongoose

As a newcomer to web development, I am currently working on creating a todo app. Below is the schema and model that I have: const tdSchema = new mongoose.Schema({ category: { type: String, required: true, unique: true }, tds: { type: ...

How to utilize the Ember generate command for an addon

In my Ember addon project, the package.json file looks like this: { "name": "my-addon-ui", "version": "1.0.0", "devDependencies": { "test-addon": "http://example.com/test-addon-1.1.1.tgz", } } Additionally, the package.json file of the depe ...

What is the impact of sending a JavaScript request to a Rails method every 15 seconds in terms of efficiency?

I have a method that scans for notifications and initiates a js.erb in response. Here is the JavaScript code triggering this method: setInterval(function () { $.ajax({ url: "http://localhost:3000/checkNotification", type: "GET" }); }, 15000); ...

Is there a way to update the content of both spans within a button component that is styled using styled-components in React?

I am interested in creating a unique button component using HTML code like the following: <button class="button_57" role="button"> <span class="text">Button</span> <span>Alternate text</span> ...

Showing PDF files using Binary Data in JQuery

Binary data is new to me, but I'm working with Laravel and have a PDF file located at storage/filename.pdf. When I retrieve the file as binary data from the backend, the response is also in binary form. https://i.sstatic.net/7FU18.jpg My goal is to ...

The module 'NgAutoCompleteModule' was declared unexpectedly by the 'AppModule'. To fix this issue, make sure to add a @Pipe/@Directive/@Component annotation

Currently, I am attempting to integrate an autocomplete feature into my Angular 2/4+ project. Despite trying various libraries, none of them seem to be working correctly. Each one presents me with a similar error message: Unexpected module 'NgAutoCom ...

Enhancing search functionality with jQuery and Ajax

How can I create a window below a search bar to show search results with names and images? For now, using a placeholder object with information like this: data: "{one : 'test',two: 'test2' }" I have a basic understanding of jQuery, bu ...

Transferring data to server using AngularJS and Java Servlet Technology

I am currently facing a challenge in developing a webpage that enables file uploads from a local machine to a server using AngularJS and Java Servlet. My approach involves sending data to the server using $http.post and attempting to read the file data usi ...

The functionality of Node async/await appears to be malfunctioning

In an effort to streamline my code and reduce the number of callbacks, I decided to explore using async/await. However, I encountered a problem where Express renders the view before the query is complete. The query results are correct, but they come after ...

There seems to be an error with cheeriojs regarding the initialization of exports.load

I am currently using cheeriojs for web scraping, but I am encountering an issue after loading the body into cheerio. Although the body appears to be well-formatted HTML code, I am receiving errors such as exports.load.initialize. This is preventing me fr ...

Can the rxjs take operator be utilized to restrict the number of observables yielded by a service?

As someone who is just starting to learn Angular, I am working on a website that needs to display a limited list of 4 cars on the homepage. To achieve this, I have created a service that fetches all the cars from the server. import { Response } from &apos ...

How can I customize button colors in react-bootstrap components?

Changing colors in react-bootstrap may be a challenge, but I'm looking to customize the color of my button beyond the primary options. Any suggestions on how I can achieve this using JS and SCSS? ...

Using the Enter key to submit HTML forms

I created a custom console using HTML, CSS, and JavaScript. The input doesn't show up when I press enter, I have to click the send button. How can I make it send on enter press? Here is the code, please assist me: /* code goes below*/ <!DOCTY ...

Is the uib-tooltip custom trigger malfunctioning?

One of the challenges I am currently facing involves implementing a tooltip on an input field. Here is my current implementation: <input id="test" uib-tooltip="my tootip" tooltip-trigger="customEvent" ng-model="test" /> I have been attempting to di ...

What is the best way to extract a thumbnail image from a video that has been embedded

As I work on embedding a video into a webpage using lightbox, I'm looking for advice on the best design approach. Should the videos be displayed as thumbnails lined up across the page? Would it be better to use a frame from the video as an image that ...

When using React-hook-form, you need to tap twice to delete the last character in the input field, and double tap to enter the first

I have been using React Hook Form to validate my form with multiple inputs. Everything works perfectly, except I noticed one issue where I have to press the backspace key twice to delete the last character and also twice to enter the first character. For e ...

jQuery Algorithm for calculating totals

Here is an algorithm for formatting amounts using jQuery: Visit jsfiddle for the code However, there are some issues. For instance, if I enter 900.800,00 and then delete the "9", it still displays 00.800,00. How can this be resolved? I have fixed severa ...

Grunt tip: Converting jshint results to HTML format

I've set up jshint to run with grunt successfully, but now I'm looking to have the output in HTML format. Below is my grunt configuration: module.exports = function(grunt) { // Project configuration. grunt.initConfig({ jshint: { ...