title: Wordpress ajax request in pure javascript (where to put action?)
body: <p>WordPress ajax request in jquery.</p>
  <p>The ajax request in jquery works but I'm trying to use pure JavaScript.</p>
  <p>How can I turn this code into pure javascript?</p>
  <pre><code>$('#camitonContactForm').submit(function(event){
  event.preventDefault();
      
  isValidationOn = true;
  validateInputs();
  
  let formaction =   $('#camitonContactForm').data('url');
  let forminput =   $('#camitonContactForm').serialize();
  
  let noncecheck = $('#camitonContactForm').data('nonce'); ;
  let formdata = new FormData;
  
  formdata.append('action', 'contact_message');
  formdata.append('nonce', noncecheck);
  formdata.append('contact_message',forminput);
  
  $.ajax(formaction, {
  
    type:'POST',
    data:formdata,
    processData: false,
    contentType:false,
  
    success: function(res){
  
    
    },
  
    error: function(err){
       alert(err.responseJSON.data);
    }
  
  });
  </code></pre>
  <p>Here I tried to write it in pure javascript but it doesn't work.</p>
  <pre><code> form.addEventListener('submit', (e) =&gt; {
    e.preventDefault();
    isValidationOn = true;
    validateInputs();
  
  
     //form action
    let formwrapper = document.getElementById('camitonContactForm');
    let formaction = formwrapper.getAttribute('data-url');
    //form nonce
    let noncecheck = formwrapper.getAttribute('data-nonce');
    //form
    let forminput =  serialize(formwrapper);
  
    
    var formdata = new FormData(form);
  
    
   /*
    formdata.append('action', 'contact_message');
    formdata.append('nonce', noncecheck);
    formdata.append('contact_message',forminput);
   */
    let  ajax = new XMLHttpRequest();
  
    ajax.open(&quot;POST&quot;,  formaction, true);
    ajax.onreadystatechange = function() {
      if(ajax.responseText == 4 &amp;&amp; ajax.status == 200){
        if(ajax.responseText == &quot;success&quot;){
            
        }else{
            statusSection.innerHTML = ajax.responseText;
            btnsection.disabled = false;
            alert('well something wrong');
        }
  
      }
    }
    ajax.send(formdata);
  
  });
  </code></pre>
  <p><strong>the serialize funcion i found on this link below
  <a href="https://stackoverflow.com/questions/11661187/form-serialize-javascript-no-framework">form serialize javascript (no framework)</a></strong></p>