简体   繁体   中英

how to include json file on node.js javascript file

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".

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 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM