Works in IE8, but not in Safari?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HawkMan24
    New Member
    • Apr 2010
    • 12

    #1

    Works in IE8, but not in Safari?

    I have a webpage where the user enters an email address and hits the tab key to activate a function onChange and I use Ajax to read a MySQL database and then displays a message if that email address is already on the database or not. It works fine in IE8, but in Safari it doesn't work. Here is my function to check for which XML Http Object:

    Code:
    function GetXmlHttpObject(){
    if (window.XMLHttpRequest)
    {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
    }
    And here is how I call it:

    Code:
    var xxmlHttp; 
    
    xxmlHttp=GetXmlHttpObject();
    if (xxmlHttp==null){
    alert ("Browser does not support HTTP Request");
    return;
    }
    I am not getting the alert, it just tabs to the next field. What am I doing wrong. I need this to work with all browsers.

    Thanks,
    Fred
  • HawkMan24
    New Member
    • Apr 2010
    • 12

    #2
    Originally posted by HawkMan24
    I have a webpage where the user enters an email address and hits the tab key to activate a function onChange and I use Ajax to read a MySQL database and then displays a message if that email address is already on the database or not. It works fine in IE8, but in Safari it doesn't work. Here is my function to check for which XML Http Object:

    Code:
    function GetXmlHttpObject(){
    if (window.XMLHttpRequest)
    {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
    }
    And here is how I call it:

    Code:
    var xxmlHttp; 
    
    xxmlHttp=GetXmlHttpObject();
    if (xxmlHttp==null){
    alert ("Browser does not support HTTP Request");
    return;
    }
    I am not getting the alert, it just tabs to the next field. What am I doing wrong. I need this to work with all browsers.

    Thanks,
    Fred
    OK, I put alerts in my function GetxmlHttpObjec t and it displays the alert saying that it got the xml requets for Safari. So why doesn't it display the message. I am sending the message to a div id tag that I have below the input textbox for the email address.

    Code:
    <div id="output1" style="color: blue;"></div>
    and here is the code to check the email address for duplicate.

    Code:
    function omrCheckEmail(){
    var divid = 'output1'; 
    var loadingmessage = 'Processing...'; 
    var xxmlHttp; 
    
    xxmlHttp=GetXmlHttpObject();
    if (xxmlHttp==null){
    alert ("Browser does not support HTTP Request");
    return;
    }
    xxmlHttp.onreadystatechange = function(){ 
    if (xxmlHttp.readyState > 0 && xxmlHttp.readyState < 4){ 
    document.getElementById(divid).innerHTML=loadingme ssage; 
    } 
    if (xxmlHttp.readyState == 4) { 
    emBoolean = xxmlHttp.responseText;
    if (emBoolean == 'true') {
    document.getElementById(divid).innerHTML="THIS EMAIL HAS REGISTERED!";
    }
    else {
    document.getElementById(divid).innerHTML="THIS EMAIL HAS NOT REGESTERED!";
    }
    } 
    } 
    
    var queryString = '&email=' + (document.getElementById('custom').value);
    
    xxmlHttp.open("POST", "omrCheckEmail.php", true);
    xxmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    xxmlHttp.setRequestHeader("Content-length", queryString.length); 
    xxmlHttp.setRequestHeader("Connection", "close"); 
    xxmlHttp.send(queryString); 
    }
    And my omrCheckEmail.p hp returns either "true" or "false" accordingly.

    Comment

    • HawkMan24
      New Member
      • Apr 2010
      • 12

      #3
      Can anyone help me with this problem?

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Does it work in Firefox?... Have you seen what's happening in Firebug or error console?

        Comment

        • HawkMan24
          New Member
          • Apr 2010
          • 12

          #5
          Originally posted by hsriat
          Does it work in Firefox?... Have you seen what's happening in Firebug or error console?
          I have only tested it on IE and Safari. It works fine on IE but not on Safari. I don't have Firefox on my computer.

          Comment

          • HawkMan24
            New Member
            • Apr 2010
            • 12

            #6
            Anybody have any ideas or suggestions? I really need to have this working in all browsers before I can put it out there. I am doing this as a volunteer for a national organization. Thanks!

            Comment

            • HawkMan24
              New Member
              • Apr 2010
              • 12

              #7
              Originally posted by HawkMan24
              Anybody have any ideas or suggestions? I really need to have this working in all browsers before I can put it out there. I am doing this as a volunteer for a national organization. Thanks!
              Figured it out, thanks for nothing folks! LOL

              Comment

              Working...