title: How to call Django REST APIs using javascript/jquery/AJAX?
body: <p>I want to call a Django Rest API in Frontend using Javascript, jQuery, AJAX. Request method is POST but when I see the API call its calling OPTIONS method. So, I came to know about <code>access-control-allow-origin</code> which needs to be allowed in APIs I guess. For that I used <code>django-CORS-headers</code> package but still its calling the <code>OPTIONS</code> method.</p>
  
  <p><strong>code</strong> is something like this :</p>
  
  <pre><code>jQuery.ajax({
              url: API_url,
              headers:headers,
              dataType: "JSON",
              type: "POST",
              crossDomain: true,
              xhrFields: {
                  withCredentials: true
              },
              success: function( response, jqXHR ) {
                      do something here
              }
  });
  </code></pre>