How to or is it even possible to make ajax call for a json file from local directory in npm parcel?

How to or is it even possible to make ajax call for a json file from local directory in npm parcel?

newbieCnewbieC Posts: 25Questions: 6Answers: 0

Link to test case: https://jsbin.com/wukunowafe/1/edit?html,js,console,output
Debugger code (debug.datatables.net): ujosok
Error messages shown: DataTables warning: table id=table2 - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Description of problem: Trying to make ajax call to json data when using npm parcel. Ajax call returns index page instead of data. Do I have to use import or require? Dynamic importing? if yes, how?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    Answer ✓

    For security reasons web browsers won't load local files via ajax. See this SO thread for more info.

    Kevin

Sign In or Register to comment.