Exploring the capabilities of arrays within Ajax

Below is the original code I wrote in JavaScript:

var wt_val = [];

        for (i = 0; i<human_wt.length; i++){
          var mult;
          mult = data_list[basket_list[button_port_name][i]].map(x => x*(wt[i]/100));
          wt_val.push(mult);
        }

The variable wt_val is either a list or a list of lists.

Next, I am sending this data to the server.

          $.ajax({
          type: 'GET',
          url: '/add',
          data: {hoot: wt_val},
          success: function(results){

            alert("success");

          },
          error: function(error) {
          }
        });

No errors occurred at this point.

However, no value is being received.

app.route('/add', methods=['GET'])
def sum():

    start = request.form.getlist('hoot[]')
    print type(start)
    print len(start)

The length of the received data is 0.

Answer №1

Make sure to follow these steps:

 parameter = { value: wt_value};

Include the following code in your post:

 $.post('..abc.aspx' + Math.random()
               , {
 data: parameter
}

For the server side, use the following code:

 var result = Request.Form("data[value][]")

I hope this information is helpful.

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

Error in Node.js: Cannot listen on socket.io object as it does not have a 'listen' method

I am currently developing a Node application using socket.io version 0.9.13 alongside Express 3.0.6. I am encountering an issue where the app fails to run due to an error stating that socket.io does not have a method called listen(). Here is the code snipp ...

I wonder what the response would be to this particular inquiry

I recently had an angular interview and encountered this question. The interviewer inquired about the meaning of the following code snippet in Angular: code; <app-main [type]="text"></app-main> ...

Unable to click on the search button due to an advertisement blocking it

Recently, I encountered an issue while running a Python script with Selenium to perform a search on a webpage using the available search box. The problem arises when an advertisement pops up upon loading the webpage through my script, hiding the search box ...

Utilizing Selenium to extract information and store it in a variable

Can Selenium actually scan the source code for specific text, such as "Last updated", and then extract the whole line containing the date and time into a variable? Here is the HTML code that needs to be copied into a variable: Last updated: <strong> ...

Tips for using selenium to input a username and password when the IDs are concealed on a webpage

I am attempting to use Python code to automate the process of filling in a username and password on a webpage. However, while the code is able to successfully open the page, it is not populating the username and password fields as expected. Below is the co ...

Why does the code require the use of window when the Javascript error object is not functioning properly?

I'm struggling to grasp the distinction between var maxResult = window.max(maxValInt1, maxValInt2); which functions properly, and var maxResult = max(maxValInt1, maxValInt2); which gives an error "object is not a function". Why do I have to inclu ...

JSON file organization

Is it possible to convert the integer values highlighted in the code snippet to string values? You can check out the image at the following link for reference: https://i.stack.imgur.com/3JbLQ.png Here is the code snippet: filename = "newsample2.csv&q ...

Having trouble accessing a URL using Selenium in Python, but the browser opens without any issues

from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys import time import datetime ch_options = webdriver.ChromeOptions() ch_options.add_argument("--user-data-dir=C:\ ...

Each time the page is refreshed, the most recent form data submitted is continually appended to an array

I have implemented a post request to add input data from a form. The entered data is stored in an array variable burg and then displayed on my index.handlebars view. Everything works as intended, but when the page is refreshed without any input in the form ...

Chrome is experiencing a delay in closing the Select Option dropdown menu

On my webpage, I have two select option buttons placed on different tabs. Whenever one button is changed, I want to update the value of the other button and assign it to a specific element like a span in the example code provided. While everything works sm ...

Creating a dynamic display of flash files on a webpage through a unique combination of PHP, AJAX, and

Despite my lack of experience with Ajax and minimal java knowledge, I have a strong background in SQL and PHP. Even though I anticipate criticism for this question, I am determined to seek help. My primary objective is to rotate 4 flash SWF files randomly ...

"Only the final graph in Seaborn displays the Mean, Median, and Mode lines

In my attempt to display the mean, median, and mode lines in two separate graphs, I encountered an issue where they are only visible in the final graph: #Splitting the window into 2 sections f, (ax_box, ax_hist) = plt.subplots(2, sharex=True, gridspec_k ...

Utilizing CSV column headers for labeling plots

When creating plots in my post-process python script for Ansys APDL analysis results, I currently manually add labels using the three columns headers ("NODE_POT_GAUCHE_i", "NODE_LISSE_CENTER_i", "NODE_POT_DROITE_i"). In my loop, I read CSV files and plot ...

Webpack and Keycloak Integration: Content blocked because of MIME type ("text/html")

I am currently using VueJS for my frontend with Keycloak handling authentication, along with Webpack to bundle my code. Upon the initial application load, if the user is not authenticated, they are redirected to the Keycloak page. During this process, an ...

Canvg | Is there a way to customize canvas elements while converting from SVG?

Recently, I encountered an issue with styling SVG graphics dynamically generated from data. The SVG graphic appears like this: To address the problem, I turned to Canvg in hopes of converting the SVG into an image or PDF using a hidden canvas element. How ...

Opening new windows in Chrome after an AJAX request behaves like a pop-up

When a user clicks a button in my application, an ajax request is triggered. Following the success of this request, I generate a URL which I intend to open in a new tab. Unfortunately, when using Chrome and calling window.open within the success handler, t ...

Is the Site Header displayed depending on the scroll position and direction of scrolling?

On my website, I have a header that I want to hide when the user scrolls down 100px and show again when they scroll up 50px. I attempted to write a script for this functionality, but it doesn't seem to be working as expected. CSS /* This CSS rule w ...

Difficulty in transferring a variable from my JavaScript file to my PHP file

Currently, I am utilizing the Instascan API to scan QR codes with the intention of sending the scanned content to my PHP file. However, regardless of whether I use POST or GET methods, the PHP file does not seem to recognize them and keeps expecting either ...

Retrieving API Data in React Using the MERN Stack

Can anyone help me understand why I'm logging an empty array [] in my console even though I'm getting results from my API? This is my Node.js code: app.get("/todos", async (req, res) => { const todos = await todo.find() res.json(todos ...

The filtering feature in AngularJS ng-options is not functioning correctly

Greetings, I am a newcomer to angular. In my current demo application, I have created a list of users with a select filter using ng-option. There seems to be a bug that I have been unable to identify. The issue: When I select the Female option, i ...