I use fullcalendar jquery plugin from http://arshaw.com/fullcalendar/ and I use knockout js on my website.
I added the event array what is the source of the calendar. The user can modify the events (array).
Then I want to serialize the event array, send by ajax, but I can not, because the calendar modifies my array, and puts an cycle into the source array. How can I remove the changes. Why is there a cycle in my array? I read, may be there is an DOM object in this.
Chrome sendrequest error: TypeError: Converting circular structure to JSON
var a = [];
a.push({
title: "Event2",
start: "2013-09-05"
});
a.push({
title: "Event2",
start: "2013-09-15"
});
$("#calendar").fullCalendar({
events: a,
header: {
left: "title",
center: "",
right: "today prev,next"
},
editable: false
});
console.log(JSON.stringify(a));
TypeError: Converting circular structure to JSON
How can I fix it? What is the cause of the cycle?
fiddle example, you can see my problem:
http://jsfiddle.net/erbsaag/XC3NH/1
The plugin is modifying your data.
If you run
console.log(a)
before your console.log you can see the issue. One solution is to only return the fields you need, and not return the fields which have cyclical recursions.
Example:
console.log(JSON.stringify(a.map(function(ai) { return {title: ai.title, start: ai.start}})));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With