Akshay Lokur
Akshay Lokur

Reputation: 7516

Unable to stringify to JSON - throws cyclic structures error

Below is my data object structure as printed out on the console of Safari:

_Api (2)
0 {company_code: 64, clerk_code: "RO", clerk_name: "Akshay", list_a: 1, list_b: 0}
1 {company_code: 64, clerk_code: "SA", clerk_name: "Lokur", list_a: 0, list_b: 1}

Now when I use JSON.stringify(data) in order to send this to server side code from Jquery $.ajax method, I am getting following error:

TypeError: JSON.stringify cannot serialize cyclic structures.

Confused how my data is cyclic..!

Any clues anyone?

Upvotes: 0

Views: 721

Answers (1)

Akshay Lokur
Akshay Lokur

Reputation: 7516

Works like this:

var data = acct_clerk_datatable.rows('.selected').data().toArray();
var json = JSON.stingify( data );

Reference: https://datatables.net/forums/discussion/36669/create-json-string-from-datatable-selected-selected-row

Upvotes: 1

Related Questions