title: handle form request with ajax in django
body: <p>i have problem with ajax when i send a request from my form it doesn't get the value from the form</p>
  
  <p>this is my view code</p>
  
  <pre><code>def create(request):
      if request.method == 'POST':
          msg_text = request.POST.get('the_massage')
          data = {}
          form = ChatApp(message=msg_text, user=request.user)
          form.save()
          data['message']=form.message
          data['user']=form.user.username
          return JsonResponse(data)
      else:
          return JsonResponse({'nothing coming thrue'})
  </code></pre>
  
  <p>it shod get the_massage variable but it give me null value</p>
  
  <p>this is my ajax function :</p>
  
  <pre><code>    $(function () {
  
  
    $('#main-form').on("submit"  ,function () {
      console.log("create function is here");
      var form = $(this);
      $.ajax({
        url: form.attr('action'),
        type: form.attr('method'),
        data: {the_massage:$('#msgbox').val()},
        dataType: 'json',
  
        success: function(json) {
  
          console.log(json);
          console.log('success');
        },
        error: function(error){
          console.log('we have error');
        },
      });
    });
  
  });
  </code></pre>
  
  <p>when i console log the value it just come through in the console
  please help me
  and show me this in the console :</p>
  
  <blockquote>
    <p>Resource interpreted as Document but transferred with MIME type
    application/json: "<a href="http://localhost:8000/create/" rel="nofollow noreferrer">http://localhost:8000/create/</a>".</p>
  </blockquote>