2

Is there a way to gain further access into the request that Fullcalendar.io sends to the server? Like, are there AJAX options I can modify?

I've examined the header, and it's sending a start and end param, plus the custom_params listed in the example below. However, it is all form data. How do I configure the request to send a JSON object instead of form data?

The documentation is kind of sparse and I am still looking for an example.

Do I use the events as a JSON feed? OR do I use the function(fetchInfo, successCallback, failureCallback)?

    events: {
      url: '[INTERNAL API / MSSQL]',
      method: 'POST',
      extraParams: {
        custom_param1: 'something',
        custom_param2: 'somethingelse'
      },
      failure: function () {
        alert('there was an error while fetching events!');
      },
      // color: 'yellow',   // a non-ajax option
      // textColor: 'black' // a non-ajax option
    },


    // events: function(fetchInfo, successCallback, failureCallback) {

    //   /*is this where I do the AJAX stuff?*/

    //   fetchInfo = {
    //     start: "",
    //     end: "",
    //     startStr: "",
    //     endStr: "",
    //     timeZone: ""
    //   }


    // },
NamedArray
  • 773
  • 3
  • 10
  • 25
  • "However, it is all form data"...because the parameters are sent as querystring parameters. Generally it's not a good idea to send JSON on the querystring. – ADyson Jun 17 '20 at 09:10
  • "do I use the function(fetchInfo, successCallback, failureCallback)?"...yes, if you want to send, for example, a POST request containing JSON for the start/end dates then you'd need to use that feature and define your own AJAX request. You're right that fullCalendar doesn't support sending that data as JSON in its config options. Or of course you can modify your server-side code to accept form data. Many APIs can accept both form data and JSON (and even XML as well) to the same endpoint, and will use the request's content-type header to decide how to decode it. – ADyson Jun 17 '20 at 09:12

0 Answers0