그래서 내 사이트에서 실시간 검색 기능을 개발했지만 Internet Explorer에서는 작동하지 않습니다. 테스트를 거쳤으며 IE9와 IE8에서는 작동하지 않으며 크롬과 파이어 폭스에서 원하는대로 작동합니다. 제가 사용했던 Ajax는 W3Schools 웹 사이트에서 가져 와서 작동하고있는 것으로 보입니다. 내가 사용했던 PHP일지도 모르지만 문제가 뭔지 잘 모르겠습니다. 나는 그것이 Ajax 또는 PHP 중 하나라고 추측하고있다. 누구 잘못 알아요? 도움이된다면, -RETRACTED URL에 있습니다. 감사! 내 HTML 문서에서Internet Explorer에서 PHP와 Ajax가 작동하지 않습니다.
Ajax를 : 라이브 검색
<script type="text/javascript">
var keyword = ''; // add this!
var city = ''; // add this!
var state = ''; // add this!
var country = ''; // add this!
function showHint(keyword, city, state, country) {
var xmlhttp;
if(keyword.length == 0 && city.length == 0 && state.length == 0) {
document.getElementById("txtHint").innerHTML = "";
}
if(window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "gethint.php?keyword=" + keyword + "&city=" + city + "&state=" + state + "&country=" + country, true);
xmlhttp.send();
}
</script>
PHP :
<?php
//get the parameters from URL
$keyword = $_GET['keyword'];
$city = $_GET['city'];
$state = $_GET['state'];
$country = $_GET['country'];
$query = mysql_query("SELECT * FROM users WHERE ClinicName LIKE '%$keyword%' AND LocationCity LIKE '%$city%' AND LocationRegion LIKE '%$state%' AND LocationCountry LIKE '%$country%' ORDER BY ClinicName ASC") or die(mysql_error());
if($query){//If query successfull
if(mysql_affected_rows()!=0){//and if atleast one record is found
echo '
<tr>
<th>Clinic Name</th>
<th>Phone Number</th>
<th>Location</th>
</tr>';
while($rows = mysql_fetch_array($query)){ //Display the record
$replace = str_replace(" ", "-", $rows['ClinicName']);
echo '
<tr>
<td><a href="clinic.php?userid='.$rows['UserID'] .'">'.$rows['ClinicName'].'</a></td>
<td>'.$rows['Phone1'].'-'.$rows['Phone2'].'-'.$rows['Phone3'].'</td>
<td>'.$rows['LocationCity'].', '.$rows['LocationRegion'].' '.$rows['LocationZip'].', '.$rows['LocationCountry'].'</td>
</tr>';
}
}
else {
echo 'No Results for:<br />Clinic Name: '.$keyword.'<br />City: '.$city.'<br />State: '.$state.'<br />Country: '.$country.'';//No Match found in the Database
}
}
else {
echo 'Parameter Missing in the URL';//If URL is invalid
}
?>
확인을 GET에 추가 또는 파이어 폭스 먼저하시기 바랍니다 –
그래, 그렇지 않습니다. 죄송합니다. –
Chrome에서 직접 테스트 해 보셨습니까? – DanRedux