Passing list of values to django view via jQuery ajax call

前端 未结 5 710
一个人的身影
一个人的身影 2020-12-01 09:38

I\'m trying to pass a list of numeric values (ids) from one web page to another with jQuery ajax call. I can\'t figure out how to pass and read all the values in the list. I

5条回答
  •  北海茫月
    2020-12-01 10:10

    You can access this array by request.POST.getlist('terid[]') in the view

    in javascript:

    $.post(postUrl, {terid: values}, function(response){
        alert(response);
    });
    

    in view.py:

    request.POST.getlist('terid[]')
    

    It works perfect for me.

提交回复
热议问题