I am trying to stringify a javascript object, however when I do this a get the following error:
TypeError: cyclic object value
I don't believe that my code contains any cyclic references (newServiceObject is not referenced inside the object), so I do not understand why I am getting this message.
I want to turn my object that contains two properties and an array into a single string.
var serviceName = $('#newServiceNameBox').val();
var serviceCodeElemList = $(.ServiceCodeName).map(function() { return $(this).html(); } );
//create the new service object
var newServiceObject = {ServiceId:-1, ServiceName: serviceName, ServiceCodes: serviceCodeElemList };
var appendNewService = '&newService='+JSON.stringify(newServiceObject);
The error occurs on the last line (the JSON.Stringify() ) but I have no idea why!