Using Arrays in Ajax

Here is my original javascript code

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);
        }

wt_val - list or list of lists.

Now I am sending this to the server.

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

            alert("success");

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

Again there is no mistake.

But here no meaning is obtained.

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

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

Length 0

+4
source share
1 answer

you will need to do something like this

 paramtoget= { pval: wt_val};

in your message

 $.post('..abc.aspx' + Math.random()
               , {
 param: paramtoget
}

server side

 var value = Request.Form("param[pval][]")

Hope this helps

+1
source

Source: https://habr.com/ru/post/1662806/


All Articles