title: JSON data parsing in Django AJAX POST Request
body: <p>I'm getting below error whenever I send a JSON object via AJAX post request in Django.</p>
  
  <pre><code>json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  </code></pre>
  
  <p><strong>Code in html:</strong></p>
  
  <pre><code> $("#submit").click(function(){
  
             var finalData{};
             finalData.name = $('#name').val();
             finalData.email = $('#email').val();
             finalData.password = $('#password').val();
             finalData.website = $('#website').val();
  
             $.ajax({
  
                    url: window.location.pathname,
                    type: "POST",
                    data :finalData,
                    success: function(){
  
                    },
                    error: function(){
  
                    }
                  });
  
              });
      });
  
  
  
      &lt;form  method = "POST" &gt;
          {% csrf_token %}
  
          &lt;div class="form-group"&gt;
            &lt;label for="name"&gt;Name:&lt;/label&gt;
            &lt;input type="text" class="form-control" id="name" placeholder="Enter name" name="name" required&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
            &lt;label for="email"&gt;Email:&lt;/label&gt;
            &lt;input type="email" class="form-control" id="email" placeholder="Enter email" name="email" &gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
            &lt;label for="pwd"&gt;Password:&lt;/label&gt;
            &lt;input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pwd" &gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
            &lt;label for="name"&gt;Website:&lt;/label&gt;
            &lt;input type="text" class="form-control" id="website" placeholder="Enter website" name="website"&gt;
          &lt;/div&gt;
  
          &lt;div class="checkbox"&gt;
            &lt;label&gt;&lt;input type="checkbox" name="remember"&gt; Remember me&lt;/label&gt;
          &lt;/div&gt;
  
          &lt;button type="submit" id="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p><strong>Code in Python:</strong></p>
  
  <pre><code>def signup(request):
  
  if request.method == 'POST':
      body = request.body
      response_json = body.decode('utf-8')
      x = json.loads(response_json)
      print(x)
  
      return render(request, 'signup.html', {})
  
  else:
      return render(request, 'signup.html', {})
  </code></pre>
  
  <p>I'm able to print the response using below command in Python </p>
  
  <pre><code>print(request.body)
  </code></pre>
  
  <p><strong>Sample JSON Data Object:</strong></p>
  
  <pre><code>{
     name: test,
     email: test@gmail.com,
     password: test,
     website: www.test.com
  }
  </code></pre>
  
  <p>What exactly am I missing here?</p>