$.ajax({
            cache: false,
            type: "POST",
            url: "/userdelete/",
            traditional:true,  //加上此项可以传数组
            dataType:'json',
            async: true,
            data:{ids:ids},
            success: function(data) {
                if (data.status == 'success') {
                    $table.bootstrapTable('remove', {field: 'id', values: ids});
                }

            },
            beforeSend: function(xhr, settings) {
                xhr.setRequestHeader("X-CSRFToken", csrftoken);
            }
        });




    if request.is_ajax():
        if request.method == 'POST':

            array = request.POST.getlist('ids')  #django接收数组


            for i in array:
               p = UserProfile.objects.get(id=i)
               p.delete()


        return HttpResponse('{"status":"success"}', content_type='application/json')

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2021-12-26
  • 2021-05-02
  • 2021-09-14
  • 2021-12-16
猜你喜欢
  • 2021-11-12
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案