title: Django; How to redirect after confirm window
body: <p>I'm working on Django project. I'm creating a delete function and I'm wondering how I can redirect to a page with ajax.</p>
  
  <p>My current <code>views.py</code> is this.</p>
  
  <pre><code>def delete_post(request, pk):
      if request.method == 'DELETE':
          post = get_object_or_404(Post, id=pk)
          post.delete()
          #redirect to a page
  </code></pre>
  
  <p><code>js</code></p>
  
  <pre><code>function deletePost(post) {
  
      if (confirm("Are you sure?")) {
          var $post = $(post)
  
          var id = $post.data('id')
          $.ajax({
              url:'/posts/delete/' + id,
              method: 'DELETE',
              beforeSend: function(xhr) {
                  xhr.setRequestHeader('X-CSRFToken', csrf_token)
          }
      })
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Seems like <code>HttpResponseRedirect</code> doesn't work with ajax.  Anyone who can give me tips? or I want to know the way to do this without ajax if it's possible.</p>