title: AJAX call not returning -- success function not being executed in Django
body: <p>I am doing AJAX calls using jQuery in Django. Everything seems to be working fine except that the ajax call is not being returned as a result the success function is not being executed. This is my jquery file</p>
  
  <pre><code>$.ajax({
            type: "POST",
            url: "/contact_us/",
            data: {
              'name': name_val,
              'email': email_val,
              'message': message_val,
              'subject': subject_val,
              'cc': cc_val,
            },
            success: function() 
            {
  
              // display success message and reset values in the form fields
              $("#reply-message").html('Your message has been sent!').fadeOut(3000, function() {});
              // clear the fields
              $("#contact-name").val("");
              $("#contact-email").val("");
              $("#contact-message").val("");
              $("#contact-subject").val("");
  
  
            }
  
          });
  </code></pre>
  
  <p>I do not know what to return in the view for an AJAX call so right now I am just returning a dummy message, but it is not working. Here is the views.py </p>
  
  <pre><code>def contact_us(request):
      if request.is_ajax():
          if request.method == 'POST':
              name = request.POST.get('name', False)
              email = request.POST.get('email', False)
              message = request.POST.get('message', False)
              subject = request.POST.get('subject', False)
              cc = request.POST.get('cc', False)
  
              recipients = ['abc@gmail.com']
              if cc:
                  recipients.append(email)
  
              from django.core.mail import send_mail
              send_mail(subject, message, email, recipients)
              return_message = "Sent mail"
              return Httpresponse(return_message)
  </code></pre>
  
  <p>The return_message is dummy, I don't even want to process it in my response. But why is the ajax call not returning,  rest everything is working fine and I am also receiving the mail.</p>
  
  <p>I just realsed that I had made a very stupid mistake I have written Httpresponse whereas it has to be HttpResponse. Now it is working absolutely fine</p>