Jquery 选择 2 Ajax+ 标签
Jquery Select2 Ajax+Tags
$("#nomlabo").select2({
//tags:true,
ajax: {
dataType: "json",
url: "includes/labotags.php",
results: function (data) {
//alert(data[1]);
return {
results: data
};
}
},
tags: ["result1", "result2", "result3", "result4"],
maximumSelectionSize: 1
});
hi i want to put the values from Data results into the "tags",
how could this work ?
我已将代码更改为从 php 获取而不是 jquery :
$("#nomlabo").select2({
tags: [
<?php
$results =array();
if ($stm = $mysqli->prepare("SELECT * FROM laboratoire")) {
$stm->execute();
$stm->store_result();
$stm->bind_result($id,$nom_labo,$id_nationalite);
while ($stm->fetch()) {
echo '"'.$nom_labo.'",';
}
}
?>
],
maximumSelectionSize: 1
});
$("#nomlabo").select2({
//tags:true,
ajax: {
dataType: "json",
url: "includes/labotags.php",
results: function (data) {
//alert(data[1]);
return {
results: data
};
}
},
tags: ["result1", "result2", "result3", "result4"],
maximumSelectionSize: 1
});
hi i want to put the values from Data results into the "tags", how could this work ?
我已将代码更改为从 php 获取而不是 jquery :
$("#nomlabo").select2({
tags: [
<?php
$results =array();
if ($stm = $mysqli->prepare("SELECT * FROM laboratoire")) {
$stm->execute();
$stm->store_result();
$stm->bind_result($id,$nom_labo,$id_nationalite);
while ($stm->fetch()) {
echo '"'.$nom_labo.'",';
}
}
?>
],
maximumSelectionSize: 1
});