<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/ddslick.js"></script>
<div id="myDropdown"></div>
<?
$req = "SELECT firstname,id " ."FROM user " ."WHERE firstname LIKE '%".$_REQUEST['term']."%' ";
$query = mysql_query($req);
while($row = mysql_fetch_array($query)) {
$results[] = array('text' => $row['firstname'],'value' => $row['id'],'selected' =>
'false','description' => $row['firstname']); }
$r=json_encode($results);
?>
<script>
$('#myDropdown').ddslick({
data:<? echo $r?>,
width:300,
selectText: "Select your preferred social network",
imagePosition:"right",
onSelected: function(selectedData){
}
});
</script>
答案 0 :(得分:0)
与上面提到的user007一样,您忘记了结束“&gt;”为最后一个脚本块。
另外:
onSelected: function(selectedData){ //callback function: do something with selectedData; } });
将抛出错误,因为注释“// calback”在结束}}之前;);标记,导致解析器抛出错误,因为您的代码格式不正确,使其无法运行。一个有用的工具是监控浏览器控制台。