JavaScript post request
var email = document.querySelector('#edit-investor-profiles-0-entity-field-email-0-value').value; if (email.length > 3) { // construct an HTTP request var xhr = new XMLHttpRequest(); var url = "/user/register/check-email" xhr.open("POST", url, true); xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); var data = JSON.stringify({"email": email}); // send the collected data as JSON xhr.send(JSON.stringify(data)); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) {