title: Sending Ajax Request to Django
body: <p>I'm pretty new to Ajax and Django and I'm trying to send a simple ajax request to a function called 'update'. But I also don't want the actual url to change in the browser when the request is sent (example www.website.com/page/ will stay the same even with an ajax request). Basically, when I try to submit the ajax request I get a 403 error from the server. I believe part of my problem could be the url mapping in urls.py...</p>
  
  <p>This is my ajax request:</p>
  
  <pre><code>$.ajax({
     type : "POST",
     url : "/page/update/",
     data : {
          data : somedata,
      },
  }).done(function(data){
          alert(data);
  });
  </code></pre>
  
  <p>This is the view it should get:</p>
  
  <pre><code>def update(request):
      if request.is_ajax():
          message = "Yes, AJAX!"
      else:
          message = "Not Ajax"
  
      return HttpResponse(message)
  </code></pre>
  
  <p>This is my urls.py</p>
  
  <pre><code>urlpatterns = patterns('',
      url(r'^$', views.index, name='index'),
      url(r'^update/$', views.update, name='update'),
  )
  </code></pre>
  
  <p>Thank you in advance for the help.</p>
  
  <p>I looked a little more deeper into the error and the error states that I need to include 
  {% csrf_token %} when sending a post back. This example <a href="https://stackoverflow.com/questions/6020928/how-to-get-post-data-in-django-1-3">how to get POST data in django 1.3</a> shows that its placed into a form however my request is only called on an on click function</p>