Send parameters to the php file that I load events
I'm trying to pass a parameter to my query that loads the events in my calendar, my calendar is set as follows:
$('#calendar').fullCalendar({
height: 450,
contentHeight: 200,
aspectRatio: 3,
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
disableDragging: true,
firstDay: 1,
weekends: true,
defaultEventMinutes:30,
monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
monthNameShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun','Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
dayNames: ['Domingo', 'Lunes', 'Martes', 'Miercoles','Jueves', 'Viernes', 'Sabado'],
dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
buttonText: {
today: 'hoy',
month: 'mes',
week: 'semana',
day: 'dia'
},
allDaySlot: false,
allDayText: 'Todo el dia',
axisFormat: 'H:mm',
events: "json-events.php?user="+$("#list").val(),
timeFormat: 'H:mm{ - H:mm}',
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
eventClick: function(calEvent, jsEvent, view) {
//alert('Event: ' + calEvent.title);
//alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
//alert('View: ' + view.name);
nombre = prompt('Introduce tu nombre','[ nombre del usuario ]');
//alert(nombre);
event.title=nombre;
// change the border color just for fun
$(this).css('border-color', 'red');
},
dayClick: function( date, allDay, jsEvent, view ) {
$("#input_date").val($.fullCalendar.formatDate( date,'yyyy-MM-dd HH:mm:ss' ));
$("#end_date").val($.fullCalendar.formatDate( date,'yyyy-MM-dd HH:mm:ss' ));
jQuery('#form_crea_evento').dialog('open');
}
});
in this line -> events: "json-events.php?user="+$("#list").val(),
"list" is a drop down list that I'm taking the value that is selected, and the onchange event refechEvents released a calendar and my PHP script is called p开发者_如何学Goerfectly but the sending parameter to get is not updated.
As I can do to pass a parameter to the php class that I load events?
Thanks and greetings
Did you try to use this selector to get the selected value from your list:
$('#list option:selected').val();
I have found that you have to stick to the documentation format for passing a variable to the php "feed" file. Adding the variable via the url (/myfeed.php?variable=something) didn't work for me.
So try passing the variable in the data: section like this. Plug in your user variable value where the 'something' is.
events: {
url: 'json-events.php',
type: 'POST',
data: {
user: 'something'
}
}
精彩评论