gpt4 book ai didi

javascript - 如何将自定义标题添加到全日历源

转载 作者:行者123 更新时间:2023-11-29 17:00:20 24 4
gpt4 key购买 nike

我需要将自定义 header 附加到 fullcalendar 的 ajax 请求。

$('#calendar').fullCalendar({
eventSources: [
{
url: '/myfeed.php',
}
]

});

我该如何定义它?

最佳答案

查看 documentation ,说明如下:

jQuery $.ajax options

You can also specify any of the jQuery $.ajax options within the same object! This allows you to easily pass additional parameters to your feed script, as well as listen to ajax callbacks.

在此之后,documentation for $.ajax()有以下选项:

headers (default: {})

Type: PlainObject

An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. (version added: 1.5)

所以下面的代码应该可以工作:

$('#calendar').fullCalendar({
eventSources: [
{
url: '/myfeed.php',
headers: { myCustomHeader: 'My Custom Value' }
}
]
});

关于javascript - 如何将自定义标题添加到全日历源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28807948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com