0

I want to include json file on javascript in node application. I have include using "require();". But i have face error:

"Uncaught ReferenceError: require is not defined".

3

1 Answer 1

1

In client side Javascript require won't work. Instead of this use jQuery.getJson()

$.getJSON( "json_file.json", function( data ) {
   //data variable having your json data 
});
Sign up to request clarification or add additional context in comments.

3 Comments

$.getJSON in nodejs ?
@RayonDabre: This is an xy question. The OP complains that javascript complains that require is not defined. That means he's not running his script in node. The OP is confused. This answer is probably correct.
Yes OP mentioned nodejs but actually he is trying to access JOSN at client side. @RayonDabre OP is confuse b/w Node and Javascript so he is trying Node's syntax in JS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.