title: Ajax does not work, instead starts default method and action
body: <p>So my problem is that ajax (or something else) does not work for a form, and what is the most strange is that there is one form which does work perfectly with AJAX. I've tried a lot of things: changed <code>input</code> with <code>button</code> and for it the type from <code>&quot;submit&quot; to &quot;button&quot;</code>, tried to use another method from jQuery <code>.post()</code> and <code>.get()</code>, tried to use <code>xmlHttpRequest</code>. I am very confused now. Maybe you can see something what i can't.Thanks</p>
  <p>EDIT: So, i've modified it a little and got this error in the console (by now there where not any errors).
  <a href="https://i.stack.imgur.com/23Xfj.png" rel="nofollow noreferrer">Error</a></p>
  <p>Html form</p>
  <pre><code>&lt;form action=&quot;./contactAction.php&quot; method=&quot;POST&quot; class=&quot;contact_form&quot; id=&quot;cform&quot;name=&quot;contactForm&quot;&gt;
          &lt;input type=&quot;text&quot; name=&quot;contactFname&quot; placeholder=&quot;Prenumele&quot; /&gt;
          &lt;input type=&quot;text&quot; name=&quot;contactLname&quot; placeholder=&quot;Numele&quot; /&gt;
          &lt;input type=&quot;text&quot; name=&quot;contactEmail&quot; placeholder=&quot;Emailul tau&quot; /&gt;
          &lt;textarea name=&quot;contactSubject&quot; placeholder=&quot;Scrie mesajul tau&quot; style=&quot;height: 200px&quot;&gt;&lt;/textarea&gt;
          &lt;button type=&quot;submit&quot; name=&quot;contactBtn&quot;&gt;Submit&lt;/button&gt;
        &lt;/form&gt;
  </code></pre>
  <p>JS</p>
  <pre><code>$(document).ready(function () {
  $(&quot;#contactBtn&quot;).click(() =&gt; {
      contactFormValidation();
  });
  </code></pre>
  <p>});</p>
  <pre><code>function contactRequest() {
  let fname = $(&quot;#contactFname&quot;);
  let lname = $(&quot;#contactLname&quot;);
  let email = $(&quot;#contactEmail&quot;);
  let subj = $(&quot;#contactSubject&quot;);
  
  $.ajax({
      type: &quot;POST&quot;,
      url: &quot;../../contactAction.php&quot;,
      data: ({&quot;constactFname&quot;: fname, &quot;contactLname&quot;: lname, &quot;contactEmail&quot;: email, &quot;contactSubject&quot;: subj}),
      dataType: &quot;html&quot;,
      success: (response) =&gt; {
          alert(&quot;Request success&quot;);
          //$(&quot;#loginPage&quot;).html(response);
      },
      error: () =&gt; {
          alert(&quot;Error :(&quot;);
      }
  });
  return false;
  </code></pre>
  <p>}</p>
  <pre><code>function contactFormValidation() {
  let $form2 = $(&quot;#contactForm&quot;);
  $form2.validate({
      wrapper: &quot;div&quot;,
      debug: false,
      rules: {
          contactFname: {
              required: true
          },
          contactLname: {
              required: true
          },
          contactEmail: {
              required: true,
              email: true
          },
          contactSubject: {
              required: true
          }
      },
      submitHandler: () =&gt; {
          alert(&quot;Submit calledd&quot;);
          contactRequest();
      }
  });
  </code></pre>
  <p>}</p>