Saving diagram to JSON returns error

I’m completely new to go.js and I’m trying to convert the Basic diagram into a JSON file:
var modelAsText=myDiagram.model.toJson();
However when I do I get this error:
GraphObject.make requires a class function or GoJS class name or name of an object builder, not: [object HTMLDocument]

I’m using go.js 2.0.11 “https://cdnjs.cloudflare.com/ajax/libs/gojs/2.0.11/go.js

That’s odd — the statement you quoted will not call GraphObject.make at all.
I suggest that you use the browser’s debugger to see where the error is actually occurring.

Are you using jQuery? Perhaps you think you are calling it in a context where $ is bound to go.GraphObject.make.

1 Like

Yes, I’m using Jquery.
At the beginning of the init() function I have: var $ = go.GraphObject.make;
Should I change the name of the variable to another?

Thanks

Yes, I’m using Jquery.
At the beginning of the init() function I have: var $ = go.GraphObject.make;
Should I change the name of the variable to another?

Thanks

Yes, try changing it to $$ or GO. This is what many of our customers using jQuery do.