根据FullCalendar文档,可以将参数传递到JSON提要。我想传递一些HTML元素值作为参数。我不知道为什么,但他们中的一些人成功通过了,而其他人却没有。例如,这一次通过:
<select id="ticketsnumber" class="form-control" name="pax">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
但这不是:
<select id="optionsfrom" class="form-control" name="depplace">
<option value="" selected="">Откуда...</option>
<option class="bold info" name="Country" value="460">Россия</option>
<option name="City" value="1">Москва (MOW)</option>
<option class="bold info" name="Country" value="359">Болгария</option>
<option name="City" value="539">ВАРНА ()</option>
<option class="bold info" name="Country" value="359">Болгария</option>
<option name="City" value="559">СОФИЯ ()</option>
<option class="bold info" name="Country" value="84">Испания</option>
<option name="City" value="19">Барселона (BCN)</option>
<option class="bold info" name="Country" value="7">США</option>
<option name="City" value="95">Нью-Йорк (N.Y)</option>
<option class="bold info" name="Country" value="53">Тайланд</option>
<option name="City" value="220">Бангкок (BKK)</option>
</select>
这就是我称事件提要的方式:
eventSources: [
{
url: "@Url.Content("~/Home/GetQuota")",
data: {
pax: $("select[name='pax'] option:selected").val(),
fromtype: $("select[name='depplace'] option:selected").attr("name"),
fromcode: $("select[name='depplace'] option:selected").val(),
totype: $("select[name='arrplace'] option:selected").attr("name"),
tocode: $("select[name='arrplace'] option:selected").val(),
airservice: $("input[name='tariffs']").val()
},
type: "POST",
error: function () {
alert('Ошибка получения квот!');
}
}
]
您想要的是动态数据参数(倒数第二)
上面的代码是在初始化fullcalendar时而不是每次查询JSON提要时获得$("select[name='depplace'] option:selected").val()
。
url: "@Url.Content("~/Home/GetQuota")",
data: function() { //runs every time the JSON script is called.
return {
pax: $("select[name='pax'] option:selected").val(),
fromtype: $("select[name='depplace'] option:selected").attr("name"),
fromcode: $("select[name='depplace'] option:selected").val(),
totype: $("select[name='arrplace'] option:selected").attr("name"),
tocode: $("select[name='arrplace'] option:selected").val(),
airservice: $("input[name='tariffs']").val()
};
}