title: Stop page from redirecting after submitting google form through AJAX
body: <p>I'm using AJAX and a google spreadsheet to collect email data for a newsletter by taking the POST data from a form field and sending it to the spreadsheet through google forms. I can't get the code to stop the page from redirecting to google's thank you page. This is the AJAX and form code below.</p>
  
  <pre><code>&lt;form class="form-inline" role="form" action="https://docs.google.com/forms/d/1TEPXPqigGuN8sayYjz-sk6H-5wAbPaImsgadM2PBFAk/formResponse" method="POST" id="newsletter-form" target="_self" onsubmit=""&gt;
      &lt;input type="text" name="entry_291075079" value="" class="form-control" id="Email" dir="auto" placeholder="example@site.com"&gt; 
  &lt;/form&gt;
  
  &lt;script&gt;
      $("#newsletter-form").submit(function(e) {
          e.preventDefault();
          $.ajax({
              url: "https://docs.google.com/forms/d/1TEPXPqigGuN8sayYjz-sk6H-5wAbPaImsgadM2PBFAk/formResponse",
              data: $(this).serialize(),
              type: "POST",
              dataType: "xml",
              success: function(data) {
                  console.log('Submission successful');
              },
              error: function(xhr, status, error) {
                  console.log('Submission failed: ' + error);
              }
          });
      });
  &lt;/script&gt;
  </code></pre>