title: How to response ajax request in Django
body: <p>I have code like this:</p>
  
  <pre><code>$(document).ready(function(){
      $('#error').hide();
      $('#submit').click(function(){
          var name = $("#name").val();
          if (name == "") {
              $("#error").show("slow");
              return false;
          }
          var pass = $("#password").val();
          if (pass == "") {
              $("#error").show("slow");
              return false;
          }
          $.ajax({
              url: "/ajax/",
              type: "POST",
              data: name,
              cache:false,
              success: function(resp){
                  alert ("resp");
              }
          });
      });
  });
  </code></pre>
  
  <p>and view in Django:</p>
  
  <pre><code>def lat_ajax(request):
      if request.POST and request.is_ajax:
          name = request.POST.get('name')
          return HttpResponse(name)
      else :
          return render_to_response('ajax_test.html',locals())
  </code></pre>
  
  <p>Where is my mistake? I'm a beginner in Django, please help me.</p>