dev/XHRConnection.js
function xhr(url, callback, data) {
        if (!window.XMLHttpRequest || !window.JSON) return;

        var request = new XMLHttpRequest();
        request.onreadystatechange = function() {
            if (callback && request.readyState == 4 && request.status == 200) {
                // server MUST return JSON text
                callback(JSON.parse(request.responseText));
            }
        };
        request.open('POST', url);

        var formData = new FormData();

        // you're passing "message" parameter
        formData.append('message', data);

        request.send(formData);
    }
function xhr(url, callback, data) {
        if (!window.XMLHttpRequest || !window.JSON) return;

        var request = new XMLHttpRequest();
        request.onreadystatechange = function() {
            if (callback && request.readyState == 4 && request.status == 200) {
                // server MUST return JSON text
                callback(JSON.parse(request.responseText));
            }
        };
        request.open('POST', url);

        var formData = new FormData();

        // you're passing "message" parameter
        formData.append('message', data);

        request.send(formData);
    }
function xhr ( url , callback , data ) { if ( ! window . XMLHttpRequest || ! window . JSON ) return ; var request = new XMLHttpRequest ( ) ; request . onreadystatechange = function ( ) { if ( callback && request . readyState == 4 && request . status == 200 ) { // server MUST return JSON text callback ( JSON . parse ( request . responseText ) ) ; } } ; request . open ( 'POST' , url ) ; var formData = new FormData ( ) ; // you're passing "message" parameter formData . append ( 'message' , data ) ; request . send ( formData ) ; }
a simple function to make XMLHttpRequests
a simple function to make XMLHttpRequests