Hi, I need to upload data to a multiple select with ajax using the jquery bootstrap-multiselect plugins: link with the method .multiselect ('dataprovider', data). the format of the varible data is an array of objects. What I have done so far is the following:
$(document).ready(function () {
$("#idpuntosAtencion").multiselect();
function ajax(url, data, id, event) {
setTimeout(function() {
$.ajax({
url: url,
type: "POST",
data: data,
success: function (respuesta) {
event.preventDefault();
$(id).multiselect('dataprovider', respuesta);
}
});
}, 900)
}
$('#ciudadId').on('change',function(event){
var data = {'ciudadId':$('#ciudadId').val()};
ajax('Funtions/bloquerTurnoAll.php',data,'#idpuntosAtencion',event);
});
$('#idpuntosAtencion').on('change',function(event){
var data = {'idpuntosAtencion':$('#idpuntosAtencion').val()};
ajax('Funtions/bloquerTurnoAll.php',data,'#consultorioId',event);
});
});
bloquerTurnoAll.php
if(isset($_POST['ciudadId']))
{
$query_puntoatencion = "SELECT puntosAtencion.idpuntosAtencion, puntosAtencion.nombre FROM puntosAtencion WHERE puntosAtencion.estado<>'I' AND puntosAtencion.ciudadId=$_POST[ciudadId]";
$puntoatencion = mysqli_query($callcenter,$query_puntoatencion) or die(mysqli_error($callcenter));
$row_puntoatencion = mysqli_fetch_assoc($puntoatencion);
$totalRows_puntoatencion = mysqli_num_rows($puntoatencion);
$option='';
if ($totalRows_puntoatencion>0) {
$option='[';
do
{
$option.="{label: '".$row_puntoatencion['nombre']."', title: '".$row_puntoatencion['nombre']."', value: '".$row_puntoatencion['idpuntosAtencion']."'},";
}
while($row_puntoatencion = mysqli_fetch_assoc($puntoatencion));
$option.=']';
}else{
echo '<option value="">Sin informacion para mostrar</option>';
}
echo $option;
}
error in the console: TypeError: invalid 'in' operand a
in the php code I try to assemble the format of the data variable of the plugins. They could help me with what happens in this.