AJAX, fonctionne pas IE, mais ailleur oui

Squad-G Messages postés 70 Statut Membre -  
Squad-G Messages postés 70 Statut Membre -
Bonjour,

Premièrement, désolé pour le nom, j'ai du tronqué afin de garder les mots clés.

Deuxièmement, mon problème. Le script affiche les villes via AJAX (depuis une base de données) selon les lettres écrites dans le champs. Voici le script dans le champs :
<input id="id_ax_adrs_city" maxlength="35" type="text" class="input_regular_text" name="ax_adrs_city" value="<?=($Array_Infos['City'] != null ? htmlentities($Array_Infos['City']) : '')?>" onkeyup="findCity(this.value)" /><span id="livesearch_city"></span>


Voici le script :
var xmlhttp;

function findCity(str){
	if(str.length == 0){
		document.getElementById('livesearch_city').innerHTML='';
		document.getElementById('livesearch_city').style.border='0px';
		return;
	}
	
	xmlhttp=GetXmlHttpObject()
	
	if(xmlhttp == null){
		alert('Your browser does not support XML HTTP Request.');
		return;
	}
	
	var url = './ajax/ax_findcity.php';
	url = url+'?q='+str;
	url = url+'&sid='+Math.random();
	
	xmlhttp.onreadystatechange=findCity_stateChanged ;
	xmlhttp.open('GET',url,true);
	xmlhttp.send(null);
}

function findCity_stateChanged(){
	if (xmlhttp.readyState == 4){
		document.getElementById('livesearch_city').innerHTML=xmlhttp.responseText;
	}
}

function GetXmlHttpObject(){
	if(window.XMLHttpRequest){
		return new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
	}
	else if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");  // code for IE6, IE5
	}
	return null;
}


Normalement, XMLHttpRequest est prit en charge sous IE8 (même émulé en IE7), mais ceci n'a pas l'air d'être le cas ici. ActiveXObject n'est pas utilisé ... je ne comprend plus rien.

Voici une image de ce que ceci donne sous FF (pareil sur tous les autres navigateurs, mais pas IE, car rien ne s'affiche) :
http://gi-001.guestimage.com/?F=f1350569fd43d185f2f1a95899be98cc.png

Merci de votre aide en avance.

Cordialement,
Squad-G.
A voir également:

1 réponse

Squad-G Messages postés 70 Statut Membre 5
 
J'oubliais, voici "ax_findcity.php" :

<?php 
chdir('../'); 
require_once('./librairies/final.php'); 
Standard_Header('Trouver une ville', true, true, true); 

header('Pragma: no-cache'); 
header('Expires: 0'); 
header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT'); 
header('Cache-Control: no-cache, must-revalidate'); 
header('Content-type: application/xml'); 

if($User->is_loaded() == true){ 
 if(isset($_REQUEST['q']) == false OR isset($_REQUEST['sid']) == false){ 
  $_REQUEST['q'] = null; 
  $_REQUEST['sid'] = null; 
 } 

 $What = $_REQUEST['q']; 
 $Sid = $_REQUEST['sid']; 
 $Render = (string)null; 

 if($What != null AND strlen($What) > 3 AND is_numeric($Sid)){ 
  $queryResults = $Query->query_locations('SELECT  DISTINCT ('loc'.'city'), 'loc'.'country', 'loc'.'region', 'country'.'printable_name' FROM 'locations' AS 'loc' LEFT JOIN 'country' ON ('country'.'iso' = 'loc'.'country') WHERE 'loc'.'city' LIKE "'.$User->escape(format_url($What)).'%" ORDER BY 'loc'.'city' LIMIT 0,7 ', __LINE__); 
   
  if(mysql_num_rows($queryResults) > 0){ 
   $Render = '<ul style="width: 200px;  list-style-type: none; overflow:auto; height: 70px; clear:both;">'; 
    
   $i=0; 
   while($resResults = mysql_fetch_assoc($queryResults)){ 
    $i++; 
    $onClick = 'document.getElementById(\'id_ax_adrs_city\').value=\''.addslashes(htmlentities($resResults['city'])).', '.htmlentities($resResults['region']).', '.htmlentities($resResults['printable_name']).'\'; document.getElementById(\'livesearch_city\').style.display=\'none\'; return false;'; 
     
    if($i==1){ 
     $Render .= '<li style="width: 175px; border: 1px solid #000000; background-color: #EEEEEE; margin-bottom: 4px;">'; 
    } 
     
    $Render .= '<span onclick="'.$onClick.'"'.($i==1 ? ' style="padding-right: 10px;"' : '').'><strong><a href="#" onclick="'.$onClick.'">'.htmlentities($resResults['city']).'</a></strong>, <em>'.htmlentities($resResults['region']).', '.htmlentities($resResults['printable_name']).'</em></span>'; 
     
    if($i==2){ 
     $Render .= '</li>'; 
    } 
     
    if($i=2){ 
     $i=0; 
    } 
    $onClick = null; 
   } 
    
   $Render .= '</ul>'; 
  } 
 } 
 else { 
  $Render = null; 
 } 
} 
else{ 
 echo 'Erreur'; 
 exit(); 
}  

echo $Render; 
Standard_Footer(true); 
?>


Désolé.
Signature non conforme ==> Supprimée
Modération CCM.
0