onReadyStatechange not being called
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: onReadyStatechange not being called

Threaded View

  1. #1
    Join Date
    Mar 2003

    onReadyStatechange not being called

    I am usinng the following code to send an email
    The code works fine in IE but in Mozilla the function readyStateChanged doesnt get a call back, therefore the user doesnt get the message box saying that his message is sent..
    I placed an alert as a first line in that function, It gets called properly in IE but not in Mozilla... any ideas,

     var xhReq;
     function createXMLHttpRequest() {
       try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
       try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
       try { return new XMLHttpRequest(); } catch(e) {}
       alert("XMLHttpRequest not supported");
       return null;
    function readyStateChanged() {
    //alert("RS called with state:"+xhReq.readyState);
         if (xhReq.readyState != 4)  { return; }
         if (xhReq.status != 200)  {
    		alert("Ooops, I was unable to send your message \nIs your internet properly working???");
         var serverResponse = xhReq.responseText;
    	alert("Cool! Your message Is gone into my inbox, I will look it as soon as possible");
    function sendMail(form)
     xhReq = createXMLHttpRequest();
    try { 
    xhReq.open("GET", "http://www.blabla.com/mailproxy.php?comments="+form.comments.value+"&realname="+form.name.value+"&email="+form.email.value, false);
    } catch (e) {
    alert("Problem occured sending your message..:");
     xhReq.onreadystatechange = readyStateChanged;
    Last edited by PeejAvery; September 27th, 2007 at 11:39 AM.
    He is not strong and powerful, who throws people down, but he is strong who withholds himself from anger

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a Codeguru.com survey!

HTML5 Development Center