Jump to content

Problem With Ajax In Internet Explorer 7


rodrick26

Recommended Posts

I have the same problem again.This works on Mozilla, Opera, Safari, but not on Internet Explorer 7.In a previous code I had this mistake:echo '<option>'.$row["codigoequipo"]; --> WRONGecho '<option value="'.$row["codigoequipo"].'">'.$row["codigoequipo"].'</option>'; --> RIGHTbut I have another problem now but a don't know wich one...I get:Notice: Undefined index: codigo in C:\xxx\xxx\getuser.php on line 3actualizar1.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Actualizar Embarcador</title><script src="selectuser.js"></script></head><body bgcolor="#99FF99"><font face="Arial"><div align="center"><h1>Actualizar un registro</h1><br><?//Conexion con la basemysql_connect("192.168.46.150","root","");echo 'Seleccione el codigo, haga los cambios y luego presione "Actualizar"<br><br>';echo '<form method="post" action="actualizar2.php">Codigo<br>';//Creamos la sentencia SQL y la ejecutamos$sql = "Select codigo From embarcadores Order By codigo";$result = mysql_db_query("embarcadores",$sql);echo '<select name="codigo" onchange="showUser(this.value)" style="width:60px;">';//Generamos el menu desplegablewhile ($row=mysql_fetch_array($result)){   echo '<option value="'.$row["codigo"].'">'.$row["codigo"].'</option>';}echo '</select><br><br><br>';?><div id="txtHint">Usted verá aqui sus datos para actualizar...</div></font></body></html>

selectuser.js

var xmlHttpfunction showUser(str){ xmlHttp=GetXmlHttpObject()if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return }var url="getuser.php"url=url+"?codigo="+strurl=url+"&sid="+Math.random()xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true)xmlHttp.send(null)}function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {  document.getElementById("txtHint").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;}

getuser.php

<?php$codigo=$_GET["codigo"];$con = mysql_connect("192.168.46.150","root","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("embarcadores", $con);$sql="SELECT * FROM embarcadores WHERE codigo = '$codigo'";$result = mysql_query($sql);?><form method="post" action="actualizar2.php"><?while($row = mysql_fetch_array($result)) { //print_r($row);exit; echo "<font face='Arial' size=2>"; echo "<table width='75%' border='0' cellspacing='0' cellpadding='0'><tr><td width='20%'>"; echo "Embarcador<br><input type='text' name='embarcador' value='". htmlentities($row['embarcador']) ."'><br><br>"; echo "Flete<br><input type='text' name='flete' value='". htmlentities($row['flete']) ."'><br><br>"; echo "Tipo Carga<br><input type='text' name='tipocarga' value='". htmlentities($row['tipocarga']) ."'><br><br>"; $a="Servicio<br><input type='text' name='servicio' "; if (isset($row['servicio'])) {   $a.= "value='". htmlentities($row['servicio']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Pais POL<br><input type='text' name='paispol'"; if (isset($row['paispol'])) {   $a.= "value='". htmlentities($row['paispol']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="POL<br><input type='text' name='pol'"; if (isset($row['pol'])) {   $a.= "value='". htmlentities($row['pol']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br></td>"; echo $a; $a="<td width='20%'>POD<br><input type='text' name='pod'"; if (isset($row['pod'])) {   $a.= "value='". htmlentities($row['pod']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Contenedor<br><input type='text' name='contenedor'"; if (isset($row['contenedor'])) {   $a.= "value='". htmlentities($row['contenedor']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Frecuencia<br><input type='text' name='frecuencia'"; if (isset($row['frecuencia'])) {   $a.= "value='". htmlentities($row['frecuencia']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Tipo Transito<br><input type='text' name='tpotransito'"; if (isset($row['tpotransito'])) {   $a.= "value='". htmlentities($row['tpotransito']) ."'>"; } else { $a.= "value=''>"; } $a.="<br><br>"; echo $a;   $a="Valor Flete<br><input type='text' name='valorflete'"; if (isset($row['valorflete'])) {   $a.= "value='". htmlentities($row['valorflete']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Bunker/BAF<br><input type='text' name='bunkerbaf'"; if (isset($row['bunkerbaf'])) {   $a.= "value='". htmlentities($row['bunkerbaf']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br></td>"; echo $a; $a="<td width='20%'>ISPS Surcharge<br><input type='text' name='ispsurcharge'"; if (isset($row['ispsurcharge'])) {   $a.= "value='". htmlentities($row['ispsurcharge']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Porteo<br><input type='text' name='porteo'"; if (isset($row['porteo'])) {   $a.= "value='". htmlentities($row['porteo']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Handling<br><input type='text' name='handling'"; if (isset($row['handling'])) {   $a.= "value='". htmlentities($row['handling']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Recargo EIS(Posicionamiento)<br><input type='text' name='eis'"; if (isset($row['eis'])) {   $a.= "value='". htmlentities($row['eis']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="War Risk Surcharge (RSC)<br><input type='text' name='rsc'"; if (isset($row['rsc'])) {   $a.= "value='". htmlentities($row['rsc']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Recargo Canal de Panama<br><input type='text' name='rcdp'"; if (isset($row['rcdp'])) {   $a.= "value='". htmlentities($row['rcdp']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br></td>"; echo $a; $a="<td width='20%'>Emergency Fuel Surcharge (EFS)<br><input type='text' name='efs'"; if (isset($row['efs'])) {   $a.= "value='". htmlentities($row['efs']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Carrier Security Surcharge (CSS)<br><input type='text' name='css'"; if (isset($row['css'])) {   $a.= "value='". htmlentities($row['css']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Recargo Carga Peligrosa<br><input type='text' name='rcp'"; if (isset($row['rcp'])) {   $a.= "value='". htmlentities($row['rcp']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Destination THC (DTHC)<br><input type='text' name='dthc'"; if (isset($row['dthc'])) {   $a.= "value='". htmlentities($row['dthc']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Documentation FEE<br><input type='text' name='dfee'"; if (isset($row['dfee'])) {   $a.= "value='". htmlentities($row['dfee']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Otros Recargos N°1<br><input type='text' name='otros1'"; if (isset($row['otros1'])) {   $a.= "value='". htmlentities($row['otros1']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br></td>"; echo $a; $a="<td width='20%'>Otros Recargos N°2<br><input type='text' name='otros2'"; if (isset($row['otros2'])) {   $a.= "value='". htmlentities($row['otros2']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; echo "<br>"; echo "<font size=4><b>Gastos Locales</b></font><br><br>"; $a="Apertura de Manifiesto<br><input type='text' name='adm'"; if (isset($row['adm'])) {   $a.= "value='". htmlentities($row['adm']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Collection FEE<br><input type='text' name='cfee'"; if (isset($row['cfee'])) {   $a.= "value='". htmlentities($row['cfee']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Desconsolidacion<br><input type='text' name='desconsol'"; if (isset($row['desconsol'])) {   $a.= "value='". htmlentities($row['desconsol']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="Fee x Documento de Embarque<br><input type='text' name='fee'"; if (isset($row['fee'])) {   $a.= "value='". htmlentities($row['fee']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; echo "<tr>"; echo "<td valign='top'> </td>"; echo "<td valign='top'> </td>"; echo "<td colspan='2' valign='top'><p><strong><br>Comentarios :</strong></p>";$a="<p>Otros Recargos N°1 : <input type='text' name='comentario1'"; if (isset($row['comentario1'])) {   $a.= "value='". htmlentities($row['comentario1']) ."'>"; } else {   $a.= "value=''>"; } $a.="<br><br>"; echo $a; $a="<p>Otros Recargos N°2 : <input type='text' name='comentario2'"; if (isset($row['comentario2'])) {   $a.= "value='". htmlentities($row['comentario2']) ."'>"; } else {   $a.= "value=''>"; } echo $a; echo "<td valign='bottom'><input name='submit' type='submit' value='   Actualizar   '>"; echo "</font></div></td>"; echo "</tr>"; echo "</font></td></tr></table>"; }?></form><?mysql_close($con);?>

Link to comment
Share on other sites

After this:var url="getuser.php"url=url+"?codigo="+strurl=url+"&sid="+Math.random()add this:alert(url);What does the URL look like that is causing problems? Does it have accented characters?
I tried that but it seems ok i thinkI get --> getuser.php?codigo=72&sid=0.008003595194755852 in the alertwhen i choose the number 72 in the "select"I don't know what is the problemthanx
Link to comment
Share on other sites

Try this: at the top of your PHP script, var_dump($_GET); Just see what's in there. The value will appear in "txtHint". (If "txtHint" is not continuously displayed, you might want to alert(xmlHttp.responseText) at the top of your javascript stateChanged function.)

Link to comment
Share on other sites

Try this: at the top of your PHP script, var_dump($_GET); Just see what's in there. The value will appear in "txtHint". (If "txtHint" is not continuously displayed, you might want to alert(xmlHttp.responseText) at the top of your javascript stateChanged function.)
I put the code "var_dump($_GET);" at the top of getuser.php In Firefox a get "array(2) { ["codigo"]=> string(2) "59" ["sid"]=> string(18) "0.8075561427856531" } " when a choose 59 in the "select", and then show all correct.In Internet Explorer i get nothing.Then a put the code "alert(xmlHttp.responseText)" in the top of selectuser.js but nothing happens in Firefox and Internet Explorer.:)
Link to comment
Share on other sites

Then a put the code "alert(xmlHttp.responseText)" in the top of selectuser.js but nothing happens in Firefox and Internet Explorer.
Yeah, that's not the right place for it. If you were able to read the output OK before, then go back to that way.Let's try something more basic. Put THIS at the top of your PHP script.echo $_ENV["REQUEST_URI"];You should get the exact value of your javascript url value.
Link to comment
Share on other sites

Yeah, that's not the right place for it. If you were able to read the output OK before, then go back to that way.Let's try something more basic. Put THIS at the top of your PHP script.echo $_ENV["REQUEST_URI"];You should get the exact value of your javascript url value.
I tried that and I get Notice: Undefined index: REQUEST_URI in D:\www\AdminEmbarcadores\embarcadores\getuser.php on line 2 on firefox and nothing on internet explorer
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...