0

i'm experiencing problems with testing my web application on firefox and internet explorer, the problem seem to be in the ajax calls made by my application to the server i realized this when i debugged my application using FIDDLER WEB DEBUGGER and i noticed that i don't get any response when im using IE or firefox.

I tried to change my request type from "GET" to "POST" and add a cache buster without any success.

Please peep my CODE:

this is where i create my ajax object:

function createXmlHttpRequestObject()
{
    var xmlHttp;
    if(window.ActiveXObject){
        try{alert(0);
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){
            xmlHttp = false;
        }
    }
    else{
        try{
            xmlHttp = new XMLHttpRequest();
        }
        catch(e){
            xmlHttp = false;
        }           
    }

    if(!xmlHttp){
        alert("Can't create object!!!");
    }
    else{
        return xmlHttp;
    }
}

and this is where i send the request:

function process(){
  var params = "word="+word;
  if(xmlHttp.readyState==0 || xmlHttp.readyState==4){
    xmlHttp.open("POST","/gwizz/scripts/definition.php",true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length",params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(params);        
  }else{
    setTimeout('process()',1000);
  }
}

Any piece of help will be much appreciated.

moor
  • 35
  • 5

1 Answers1

0

@Moor I can't answer exactly what is wrong but here are some pointers that may help you.

  • XMLHttpRequest - Perhaps this is a bit of topic but think its useful for more browser independent code. I suggest using to create Ajax request and use ActiveXObject only in case you can't find XMLHttpRequest. Most browsers including IE8+ support this object so you have less code dependent on browsers. e.g. below copied from http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

    var xmlHttp;
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    } else {
       // code for IE6, IE5
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
  • Use Developer tools Firefox and IE modern versions come with very useful developer tools. Check the network sections and then perform clicks on your web application that are expected to invoke the ajax call. The full details of the http request actually fired are available in the network section. It will show you how the browser sees the request.

  • use console.log This question talks about some logging support which is available in IE. The same is also available in firefox. You should be able to pin point where your code execution fails. Does IE9 support console.log, and is it a real function?

If I were to take a guess, I would say the URL that is used to connect to the server may be resulting in 404.

Community
  • 1
  • 1
vvs
  • 1,066
  • 8
  • 16