search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

DayPilot.request broken after update

Asked by Mikael
2 years ago.

After updating from version 444 to 3110 (about 3 year old version to newest), I've started to get error on the AJAX DayPilot.request.

daypilot-all.min.js:14 Uncaught TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at Object.DayPilot.JSON.stringify (daypilot-all.min.js:14)
at Object.DayPilot.request (daypilot-all.min.js:10)
at DayPilot.Scheduler.dp.onEventMoved ((index):979)
at d (daypilot-all.min.js:24)
at DayPilot.Scheduler.Va (daypilot-all.min.js:24)
at HTMLDocument.n.gMouseUp (daypilot-all.min.js:31)

With the standard calls like shown in https://code.daypilot.org/50604/ajax-scheduler-for-javascript-php .
I really love the many new features available but would be nice if there is a simple and quick fix to this bug.
The error is before the network call is initiated (looked in the developer tools network tab).

Please advise guys....

Answer posted by Dan Letecky [DayPilot]
2 years ago.

This happens because the "args" object has been extended with new properties (including a reference to DayPilot.Scheduler instance) and it can't be serialized using JSON.stringify() anymore.

It's necessary to replace the "args" object in DayPilot.request calls with a custom object that selects the required properties, e.g.

dp.onEventMoved = function (args) {
    var params = { id: args.e.id(), newStart: args.newStart, newEnd: args.newEnd, newResource: args.newResource };
    DayPilot.request(
        "backend_move.php", 
        function(req) { // success
            var response = eval("(" + req.responseText + ")");
            if (response && response.result) {
                dp.message("Moved: " + response.message);
            }
        },
        params,  // used to be args
        function(req) {  // error
            dp.message("Saving failed");
        }
    );        
};
Comment posted by Mikael
2 years ago.

Thank you for the quick reply.
That solved the problem :-)

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.