How can i auto-hide the message "You have been subscribed to our newsletter " after sometime?

  ajax, ajaxform, asp.net, contact-form, javascript

The message "You have subscribed to our newsletter" is not auto-hiding itself, i have to refresh the page every time i need to enter a new entry in page and also i want the form area to be blank .see in the below image i want to hide that subscription message after sometime on its own and email area should also be blank to get a new entry.

 <script type="text/javascript">
function doSubscribe() {
    var subscriberEmail = document.getElementById("subscriberEmail").value;
     
    var ajax = new XMLHttpRequest();
    ajax.open("POST", "subscribe-newsletter.php", true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     
    ajax.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("subscribe-message").innerHTML = "You have been subscribed to our newsletter.";
           
        }
        
    };

    ajax.send("subscriberEmail=" + subscriberEmail);
    return false;
}

what should do so the message autohides itself without refreshing the page and the email area should also be blank.

Source: Ask Javascript Questions

LEAVE A COMMENT