我正在使用select2插件從mysql填充標籤。 所以我傳遞將q變量的getdada.php.but問題是爲什麼變量不被傳遞?
q變量沒有被傳遞訪問getdata.php。我想通過這個變量,這樣我可以得到有關它的數據(可能是我沒有把q變量放在合適的地方)
2.if我不使用q變量,那麼只有最後或第一個變量retrived.I想填充所有的結果作爲標籤數據(也許錯誤是在我的jsoncode在getdata.php甲酸鹽)
Plz的幫助。
$("#e8").select2({
placeholder: "Search for another Concept",
minimumInputLength: 1,
multiple: true,
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
url: "getdata.php",
dataType: 'json',
data: function (term, page) {
return {
q: term, // search term
page: page
};
},
results: function (data, page) {
return { results: data};
}
}
});
這裏訪問getdata.php
$sql=mysqli_query($db3,"SELECT * FROM o4_tags");
while($row=mysqli_fetch_array($sql)){
$tags=$row['tag_name'];
$id=$row['id'];
$myArray = array(
array("id" => "$id", "text" => "$tags"),
);
}
echo json_encode($myArray);
以防萬一有人需要這個:這裏是Select2他在談論http://ivaynberg.github.com/select2/ – Hazzit 2013-03-26 23:23:11