title: post method with jquery ajax
body: <p>Hi all I have following code: <a href="https://codesandbox.io/s/jquery-playground-forked-uw3xl" rel="nofollow noreferrer">my code</a></p>
  <p>I am trying to do simple post method on ajax but I have some difficult.</p>
  <p>First of all I have 4 inputs (name, mail, phone and country), on select with some option and textarea.</p>
  <pre><code>    &lt;form id=&quot;sendMessage&quot;&gt;
           &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;name form-control&quot; placeholder=&quot;name&quot; required&gt;
           &lt;input type=&quot;email&quot; name=&quot;mail&quot; class=&quot;email form-control&quot; placeholder=&quot;mail&quot; required&gt;
           &lt;input type=&quot;number&quot; name=&quot;phone&quot; class=&quot;phone-number form-control&quot; placeholder=&quot;phone&quot; 
             required&gt;
           &lt;input type=&quot;text&quot; name=&quot;country&quot; class=&quot;country form-control&quot; placeholder=&quot;country&quot; 
             required&gt;
           &lt;select name=&quot;theme&quot; required&gt;
             &lt;option value=&quot;&quot;&gt;choose theme&lt;/option&gt;
             &lt;option value=&quot;greenColor&quot;&gt;green&lt;/option&gt;
             &lt;option value=&quot;redColor&quot;&gt;red&lt;/option&gt;
             &lt;option value=&quot;blueColor&quot;&gt;blue&lt;/option&gt;
             &lt;option value=&quot;otherColor&quot;&gt;something else...&lt;/option&gt;
           &lt;/select&gt;
           &lt;textarea class=&quot;textBody form-control&quot; placeholder=&quot;Сообщение&quot; rows=&quot;5&quot; name=&quot;message&quot; 
             required&gt;&lt;/textarea&gt;
           &lt;button type=&quot;submit&quot; name=&quot;submit&quot;  &gt;Send&lt;/button&gt;
       &lt;/form&gt;
  </code></pre>
  <p>The scenario is following, when user will fill all fields I want to send all information to backend after submit button but something went wrong.</p>
  <pre><code>    $(&quot;#sendMessage button&quot;).on(&quot;click&quot;, (e) =&gt; {
      e.preventDefault();
      let isOk = true;
  
      let name = $(&quot;#sendMessage .name&quot;)[0].value;
      if (name) isOk = true;
      isOk = false;
  
      let email = $(&quot;#sendMessage .email&quot;)[0].value;
      if (email) isOk = true;
      isOk = false;
  
      let phoneNumber = $(&quot;#sendMessage .phone-number&quot;)[0].value;
      if (phoneNumber) isOk = true;
      isOk = false;
  
      let country = $(&quot;#sendMessage .country&quot;)[0].value;
      if (country) isOk = true;
      isOk = false;
  
      let textBody = $(&quot;#sendMessage .textBody&quot;)[0].value;
      if (textBody) isOk = true;
      isOk = false;
  
      if (isOk) {
      $.ajax({
        url: &quot;api/Guest/SendEmailForContact&quot;,
        method: &quot;POST&quot;,
        xhrFields: {
          withCredentials: true
        },
        statusCode: {
          404: function () {
            alert(&quot;page not found&quot;);
          }
        },
        context: {}
      }).done(function () {
        console.log(&quot;:asdfasdfasdf&quot;);
      });
      }
    });
  </code></pre>
  <p>Please help me to resolve that problem. Thank you</p>