function _submitForm() {
    var DONE_CODE = 4;
    var SUCCESS_CODES = {
      200: 'ok',
      201: 'created',
      202: 'accepted',
      203: 'non-authoritative info',
      204: 'no content',
      205: 'reset content',
      206: 'partial content'
    };
    var message;
    var heading;
    var state = 'ERROR';
    var xhr = new XMLHttpRequest();
    xhr.open( 'POST', _formElement.action );
    xhr.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' );
    xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
    xhr.onreadystatechange = function() {
      if ( xhr.readyState === DONE_CODE ) {
        if ( xhr.status in SUCCESS_CODES ) {
          var result;
          try {
            var response = JSON.parse( xhr.responseText );
            result = response.result;
            message = response.message;
            heading = response.header;
          } catch( err ) {
            // ignore lack of response
          }
          state = result === 'fail' ? 'ERROR' : 'SUCCESS';
        }
        if ( state === 'SUCCESS' && opts.replaceForm ) {
          heading = heading || 'Thank you!';
          _replaceFormWithNotification( heading + ' ' + message );
        } else {
          _displayNotification( _notification[state],
                              message || FORM_MESSAGES[state] );
        }
      }
    };
    xhr.send( _serializeFormData() );
  }
/**
   * Sends form data and displays notification on success / failure.
   * @param {formData} form data object with field name/value pairs
   */
Sends form data and displays notification on success / failure.
@param {formData} form data object with field name/value pairs
Sends form data and displays notification on success / failure . @param { formData } form data object with field name / value pairs
function _submitForm() {
    var DONE_CODE = 4;
    var SUCCESS_CODES = {
      200: 'ok',
      201: 'created',
      202: 'accepted',
      203: 'non-authoritative info',
      204: 'no content',
      205: 'reset content',
      206: 'partial content'
    };
    var message;
    var heading;
    var state = 'ERROR';
    var xhr = new XMLHttpRequest();
    xhr.open( 'POST', _formElement.action );
    xhr.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' );
    xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
    xhr.onreadystatechange = function() {
      if ( xhr.readyState === DONE_CODE ) {
        if ( xhr.status in SUCCESS_CODES ) {
          var result;
          try {
            var response = JSON.parse( xhr.responseText );
            result = response.result;
            message = response.message;
            heading = response.header;
          } catch( err ) {
          }
          state = result === 'fail' ? 'ERROR' : 'SUCCESS';
        }
        if ( state === 'SUCCESS' && opts.replaceForm ) {
          heading = heading || 'Thank you!';
          _replaceFormWithNotification( heading + ' ' + message );
        } else {
          _displayNotification( _notification[state],
                              message || FORM_MESSAGES[state] );
        }
      }
    };
    xhr.send( _serializeFormData() );
  }
function _submitForm ( ) { var DONE_CODE = 4 ; var SUCCESS_CODES = { 200 : 'ok' , 201 : 'created' , 202 : 'accepted' , 203 : 'non-authoritative info' , 204 : 'no content' , 205 : 'reset content' , 206 : 'partial content' } ; var message ; var heading ; var state = 'ERROR' ; var xhr = new XMLHttpRequest ( ) ; xhr . open ( 'POST' , _formElement . action ) ; xhr . setRequestHeader ( 'Content-type' , 'application/x-www-form-urlencoded' ) ; xhr . setRequestHeader ( 'X-Requested-With' , 'XMLHttpRequest' ) ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState === DONE_CODE ) { if ( xhr . status in SUCCESS_CODES ) { var result ; try { var response = JSON . parse ( xhr . responseText ) ; result = response . result ; message = response . message ; heading = response . header ; } catch ( err ) { } state = result === 'fail' ? 'ERROR' : 'SUCCESS' ; } if ( state === 'SUCCESS' && opts . replaceForm ) { heading = heading || 'Thank you!' ; _replaceFormWithNotification ( heading + ' ' + message ) ; } else { _displayNotification ( _notification [ state ] , message || FORM_MESSAGES [ state ] ) ; } } } ; xhr . send ( _serializeFormData ( ) ) ; }
Sends form data and displays notification on success / failure.
Sends form data and displays notification on success / failure .
// ignore lack of response