2012-08-14 109 views
0

這個自動完成擴展工作完全不工作,但我不什麼它停止工作,沒有JavaScript錯誤來了。這裏的原因是我的代碼自動完成擴展在PHP

<script src="scripts/jquery-1.4.1.js" type="text/javascript"></script> 

    <script src="scripts/jquery-ui.min.js" type="text/javascript"></script> 
    <link href="scripts/jquery-ui.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript"> 
    $(function() { 

    $("#autocomplete").autocomplete({ 
     source: "searchEAN.php", 
     minLength: 2,//search after two characters 
     select: function(event,ui){ 
     // alert ($value.$id); 
     alert (ui.item.value); 
     //do something, like search for your hotel detail page 
     } 
    }); 
    }); 
    </script> 
</head> 
<body> 

<div class="demo"> 
    <div class="ui-widget"> 
    <label for="autocomplete">Hotel Name: </label> 
    <input id="autocomplete" name="autocomplete"/> 
    </div> 
</div> 

,這是searchEAN.php頁面代碼。它的返回數據時,我直接通過傳遞條款查詢字符串運行該頁面

<?php 

include_once('config.php'); 

if (isset($_GET['term'])) { 
$term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends  
$qstring = "SELECT Distinct CONCAT(City,',',StateProvince,',',Country) AS value,EANHotelID AS id FROM ActivePropertyList WHERE City LIKE '%".$term."%' GROUP BY value limit 0,10 "; 
echo $qstring; 
$result = mysql_query($qstring);//query the database for entries containing the term 

while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//loop through the retrieved values 
{ 
    $row['value']=htmlentities(stripslashes($row['value'])); 
    $row['id']=(int)$row['id']; 
    $row_set[] = $row;//build an array 
} 
echo json_encode($row_set);//format the array into json data 
mysql_close(); 
} 


?> 

searchEAN.php可以查看這裏.live鏈接,並自動完成,這是不工作可以檢查here

回答

1
  • echo $qstring;在你PHP腳本。註釋掉!
+0

@lorga是的,我也發現只是在把問題放在這裏之後。謝謝你的時間。我會接受你的回答謝謝 – rahularyansharma 2012-08-14 11:01:52

0

對不起,問題解決了是我的錯誤,我回應查詢來檢查它,但忘了發表評論。那是它沒有工作的原因。

我註釋掉

//echo $qstring; in searchEAN.php file 

其現在的工作

感謝

相關問題