Start New Discussion within our Web Development Community

Hi i am working with an web application. in my webapp on the browser i am intiating an ajax call to update part of the page. I get the response as html from the server and i will insert the complete response into the div which displays it. I got a serious problem here. when server throws a page with 404 error then i should not display anything. I mean i should ignore that response. How this can be done? Thanks in advance. I am struggling with this from so long.

The following is my code. please have a look at it.

function getHTTPObject() {
        if (typeof XMLHttpRequest != 'undefined') {
            return new XMLHttpRequest();
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                return new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        return false;

    <script type="text/javascript">                      
            function getSearchStudents(){
                document.getElementById("noStudent").style.visibility = "hidden";
                var userString=document.getElementById("userString").value;
                var http=getHTTPObject();
      "GET", ""+userString, true);              
                http.onreadystatechange = function() {
                    if (http.readyState == 4) {
                            document.getElementById("noStudent").style.visibility = "visible";
                                document.getElementById("noStudent").style.visibility = "visible";
if (http.readyState == 4 && http.status == 200)

status respresents the HTTP response code, 200 is OK, it can also be 404.

This question has already been answered. Start a new discussion instead.