Sample code:     
var element = document.getElementById(element_id);
        element.innerHTML = '<p><em>Loading ...</em></p>';
        xmlhttp.open("GET", fragment_url);
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                element.innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(null);
xmlhttp.readyState change when your Ajax request is processed and the server responds.
xmlhttp.status gives you the return code from the server
xmlhttp.responseText gives you the response from the server - you can use this to ascertain whether your business logic is a success or a failure (send some error msg and check for it here)