title: Django Insert html into div using jquery .ajax() on button click
body: <p>I need help inserting html into an empty div using .ajax(). I have the code below in a django project. The view and url work fine as does the alert message of the ajax .click function. The .ajax() 'success:' property is underlined as unused in pycharm.</p>
  
  <p>The view is as follows:</p>
  
  <pre><code>def gen_teams(request):
      return HttpResponse("&lt;h1&gt;Hello World&lt;/h1&gt;")
  </code></pre>
  
  <p>urls:</p>
  
  <pre><code>url(r'^gen_teams/$', home_views.gen_teams, name='gen_teams'),
  </code></pre>
  
  <p>main.js:</p>
  
  <pre><code>$('#ajaxSubmit').click(function(){
  alert('Creating Teams');
  var ajaxDiv = $('#ajaxContent');
  $.ajax({
      url:"http://127.0.0.1:8000/gen_teams/",
      datatype:"html",
      type: "POST",
      success: function(data) {
          ajaxDiv.replaceWith(ajaxDiv.html(data));
      }
    });
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>    &lt;p&gt;&lt;button id="ajaxSubmit" class="btn btn-primary" onclick=""&gt;Ajax teams&lt;/button&gt;&lt;/p&gt;
      &lt;div id="ajaxContent" class="content-container"&gt;
  
      &lt;/div&gt;
  </code></pre>