...

View Full Version : Works in IE not in firefox



shankari
11-04-2008, 01:01 PM
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.


//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
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>';
}
?>

shyam
11-04-2008, 01:13 PM
//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? :eek:

shankari
11-04-2008, 01:53 PM
hi,
I am using get in ajax but while getting the form values i'm using post method.


<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>

shankari
11-05-2008, 12:12 PM
is it because you are always using the GET method? :eek:
I changed it but it doesn't help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum