title: how to use Ajax with Python flask
body: <p>I have written, AJAX script using Jquery. When I debug through the script, I noticed that it doesn't go through 'success' and 'error' but it exists.</p>
  
  <p>Here is the JQuery code</p>
  
  <pre><code>$(document).ready(function(){
  
      $('#report-submit').click(function() {
          alert('inside click');
  
          $.ajax({
  
              url: '/admin/file/start/rerun_reports/',
              //data: $i('form').serialize(),
              type: 'POST',
              success: function(response) {
                  //alert(response);
                  console.log("it works..................");
                  console.log(response);
                  $("#log-results").html(response);
              },
              error: function(error) {
                  console.log(error);
              }
          });
      });
  
  });
  </code></pre>
  
  <p>However, when I submit the the button, I get the data to browser without Ajax.</p>
  
  <p>Here is the html code</p>
  
  <pre><code>&lt;form method="POST" action="/admin/file/start/rerun_reports/"&gt;
                  &lt;input name="_csrf_token" type=hidden value="{{ csrf_token() }}"&gt;
                  &lt;input class="btn btn-danger btn-lg" id="report-submit"
                      type="submit" value="submit"&gt;
  
              &lt;/form&gt;
  </code></pre>
  
  <p>Here I send the data to browser</p>
  
  <pre><code>return render_template('tools.html', data = json.dumps(start.logdata))
  </code></pre>
  
  <p>When print the status code. I get the <code>403 error</code>.</p>