Uncaught RangeError: Maximum call stack size exceeded at buildParams

Uncaught RangeError: Maximum call stack size exceeded at buildParams

我找不到哪里错了。请帮助

当我提交表单时,控制台出现以下错误

 Uncaught RangeError: Maximum call stack size exceeded     at buildParams

我看到了不同的答案,但它们没有帮助我找出错误

Jquery

<script type="text/javascript">
    var frm = $('#message-form');
    frm.on('submit',function(e){
            e.preventDefault();
            $.ajax({
                type: frm.attr("method"),
                url: "message/message_form/",
                dataType: 'json', 
                data: { csrfmiddlewaretoken: "{{ csrf_token }}", frm:frm},
            })
            .done(function(response){
             console.log(response.message)
            });
        });
</script>

HTML

<div class="fixed-bottom">
    <form id="message-form"  user_id="{{u.id}}" method="POST">
        <input type="hidden" id="user_id" name="user_id" value="{{u.id}}">
        {% csrf_token %}
        <div class="container">
            <div class="row">
                <div id="text" class="col-10">
                    {{ msgform.text }}
                </div>

                <div class="col-1">
                    <button id="submit" class="btn"  type="submit"><img height="30px" src="/static/img/send-button.png" alt="send"></button>
                </div>
            </div>
        </div><br>
    </form>  
</div>

感谢进阶

发送数据的问题

当我使用JSON.stringify到post数据时 并在视图中接受 json.loads(request.POST.get('frm')) 一切正常

$('#messageform').on('submit', function(e) {
  e.preventDefault();
  var frm = {
    'user_id': $('#user_id').attr('value'),
    'text': $('#form_message').val()
  };
  frm = JSON.stringify(frm);
  
  $.ajax({
    type: 'POST',
    url: "message/message_form/",
    dataType: 'json',
    data: {
      csrfmiddlewaretoken: "{{ csrf_token }}",
      'frm': frm
    },
  })
});

views.py

def post(self, request):
        dictionary = json.loads(request.POST.get('frm'))
        print('=================',dictionary)
        u = get_object_or_404(User,pk=dictionary['user_id'])
        msg = message.objects.filter(sender=request.user).filter(receiver=u).all() | message.objects.filter(sender=u).filter(receiver=request.user).all()
        u = message.objects.create(sender=request.user,receiver=u,text=dictionary['text'])
        #if request.user != u and u.objects.filter(receiver__sender=request.user,receiver__receiver=u,receiver__read=False).exists :
        #    notify.send(request.user, recipient=u, verb="message you please read in message box",public=False)
        # msg = message.objects.filter(sender=request.user).filter(receiver=u).all() | message.objects.filter(sender=u).filter(receiver=request.user).all() 
        msg = dictionary['text']
        data = { "message":msg}
        return HttpResponse(json.dumps(data), content_type='application/json')