ReferenceError: $ is not defined


I want to compile following code using Jurassic engine.

$(document).ready(function () { var test = 'test'; })

I tried to do it by using following code

string str = "$(document).ready(function () { var test = 'test'; })";
var engine = new Jurassic.ScriptEngine();

Then I got an error saying "ReferenceError: $ is not defined"
How can I overcome this issue?
Closed Nov 30, 2015 at 1:01 AM by paulbartrum
Not a bug.


paulbartrum wrote Nov 30, 2015 at 1:01 AM

I think you have misinterpreted what Jurassic is. Jurassic is a javascript engine, not a web browser. In a web browser "document" is defined as a reference to the HTML document. Since Jurassic is not a web browser and has no knowledge of HTML, "document" is not defined.

"$" is also not defined, but for a different reason: because that is a jQuery convention, and you have not included jQuery. (Not that you can include jQuery in Jurassic; it requires a web browser engine)