ajax in firefox..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • senthilarumugams
    New Member
    • Apr 2009
    • 5

    ajax in firefox..

    Hi i have a simple code which is working in I.E but not working in firefox.I have given the code here.. Thankyou..
    javascript:

    Code:
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
             <html xmlns="http://www.w3.org/1999/xhtml">
       
         <head>
       
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
             <title>Ajax - PHP example</title>
       
          </head>
     
          <body>
       
          <script language="javascript" type="text/javascript">
      
          <!--
      
          // Get the HTTP Object
      
          function getHTTPObject(){
      
          if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
      
          else if (window.XMLHttpRequest) return new XMLHttpRequest();
      
          else {
      
          alert("Your browser does not support AJAX.");
      
          return null;
      
          }
      
          }
      
          // Change the value of the outputText field
      
          function setOutput(){
      
          if(httpObject.readyState == 4){
            
         document.getElementById('outputText').value = httpObject.responseText;
                 
          }      
      
          }
       
          // Implement business logic
            function doWork(){
      
          httpObject = getHTTPObject();
      
          if (httpObject != null) {
      
          httpObject.open("GET", "upperCase.php?inputText="
      
          +document.getElementById('inputText').value, true);
      
          httpObject.send(null);
      
          httpObject.onreadystatechange = setOutput;
      
          }
      
          }
       
          var httpObject = null;
      
          //-->
      
          </script>
       
          <form name="testForm">
      
          Input text: <input type="text" onkeyup="doWork();" name="inputText" id="inputText" />
      
          Output text: <input type="text" name="outputText" id="outputText" />
      
          </form>
      
          </body>
      
          </html>
    Php:
    Code:
    <?php
      
          if (isset($_GET['inputText']))
    
          echo strtoupper($_GET['inputText']);
    
          ?>
    Last edited by Dormilich; Apr 2 '09, 07:51 AM. Reason: added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Put the onreadystatecha nge line before open().

    Comment

    • senthilarumugams
      New Member
      • Apr 2009
      • 5

      #3
      Thank you for your reply but is not working in firefox 3.It is working in explorer

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        I just tested your original posted code in FF3 and it worked absolutely fine. Are you sure you haven't got any other code?

        Comment

        • senthilarumugams
          New Member
          • Apr 2009
          • 5

          #5
          I think there is something wrong with the server.Is there anything i need to enable for php to work.Thank you..

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            But if it's working in IE, maybe it's not. To confirm whether it is, test the PHP file directly without using Ajax.

            Comment

            • senthilarumugams
              New Member
              • Apr 2009
              • 5

              #7
              sorry to disturb you again.Which version of firefox you tried .i have mozilla firfox 3.0.8

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                The same version on Windows.

                Comment

                • senthilarumugams
                  New Member
                  • Apr 2009
                  • 5

                  #9
                  I think the problem is with the url.If i simply give uppercase.php then it is showing the status code. If i give the server path (10.10.2.46:400 1/uppercase.php) then it is not even going inside the setoutput function but it is working in internet explorer.could you please tell me what could be the reason.how did you give the path to the server side php.
                  Thankyou..

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Yes, use a relative path. There's no need to specify the full path.

                    Comment

                    Working...