Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Works in IE not in firefox

    Hi all,
    I am having a problem in ajax which works good in IE not in firefox.
    The thing is i'm trying to get the value of textbox when submitting the form.
    This statement (echo $_POST['track'] below gives a null value.
    Code:
    //order.php
    <script language="javascript" type="text/javascript">
    
    var xmlHttp;
    function distrack(str)
    { 
    var str;	
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
     {
     alert ("Browser does not support HTTP Request");
     return;
     }
    var url="track.php";
    
    var s = document.getElementById('oid').value;
    url=url+"?q=3&oid=146;
    //url=url+"?oid="+s
    url=url+"&sid="+Math.random();
    
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
     { 
    //alert(xmlHttp.responseText);
     document.getElementById("tracknumber").innerHTML=xmlHttp.responseText; 
     } 
    }
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
     {
     // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
     }
    catch (e)
     {
     //Internet Explorer
     try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
     catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     }
    return xmlHttp;
    }
    
    	</script>
    <?php
    if ($_POST['submit'] == "submit") {
    echo   $_POST['track'];
    }
    ?>
    <form method="post" action="order.php">
    <table>
    <tr>         
               <td colspan="2" class="main" id="tracknumber">&nbsp;
               </td>
    <td><input type="submit" value="submit"></td>
     </tr>
          
                </table>
    </form>

    //track.php
    PHP Code:
    <?php
    include ('dbconnection.php');
    $q=$_GET["q"];
    $oid$_GET["oid"];



    $oid_query mysql_query("select * from orders_status_history where orders_id ='$oid' order by date_added desc limit 1");

       while (
    $row mysql_fetch_array($oid_query)) {
            
    $stid $row['orders_status_id'];
                    if (
    $stid == 3) {
                  
                     
    $trackno $row['track_number'];
                       }
              
              }

    if ((
    $q == 3)  ) {
    echo 
    '<div id="tracknumber"><b> Tracking Number :</b>';
    echo 
    '<input id="track"  type="text" name="track" value="'.$trackno.'" ></div>';
    }
    ?>
    Last edited by shankari; 11-04-2008 at 12:03 PM.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by shankari View Post
    Code:
    //order.php
    <script language="javascript" type="text/javascript">
    
    var xmlHttp;
    function distrack(str)
    { 
    var str;	
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
     {
     alert ("Browser does not support HTTP Request");
     return;
     }
    var url="track.php";
    
    var s = document.getElementById('oid').value;
    url=url+"?q=3&oid=146;
    //url=url+"?oid="+s
    url=url+"&sid="+Math.random();
    
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }
    ...
    is it because you are always using the GET method?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    hi,
    I am using get in ajax but while getting the form values i'm using post method.

    Code:
    <form method="post" action="order.php">
    <table>
    <tr>         
               <td colspan="2" class="main" id="tracknumber">&nbsp;
               </td>
    <td><input type="submit" value="submit"></td>
     </tr>
          
                </table>
    </form>

  • #4
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by shyam View Post
    is it because you are always using the GET method?
    I changed it but it doesn't help.


  •  

    Posting Permissions

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