The JSON file opens perfectly in Notepad++, but refuses to load on the webpage when accessed locally

I am currently facing an issue where I need to load a local JSON file for development and testing purposes. The HTML file I am working on is in the same directory and resides locally on the C drive. Notepad++ recognizes this as a file and automatically converts it into a link. When I double-click it, the file opens without any problem. However, the JSON file fails to load on my web page. Despite trying various combinations of slashes, I have been unable to determine why it won't load. There are no errors shown in the page console either.

$.getJSON("file://C:/Users/ME/Desktop/Test/data.json", function(data) {

Is there a way to remove the "file://" part and only display the file name? This would be beneficial when sharing the folder with a friend, as I do not want them to go through the hassle of editing the link. Are there any suggestions on what I can do in this situation?

Thank you for your assistance!

Answer №1

If you're using Windows, it's possible that Chrome is located in your AppData folder:

"C:\Users\AppData\Local\Google\Chrome\Application"

Be sure to close all Chrome windows before running the command, otherwise the command line parameter won't work effectively.

"chrome.exe --allow-file-access-from-files

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tutorial: Implementing InfoWindows for Markers in Google Maps API V3 in a C# Web Page

Here's my newbie question, hope the formatting is correct :) I'm working on an ASP.NET, C# application that retrieves coordinates (Lat, Lon) from SQL and displays them as markers (which is working fine). However, when I try to add infowindow ...

The error message reads: `json.decoder.JSONDecodeError: Unexpected additional data present at line 2, starting from column 1 (character

I encountered an error: (json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 5357)) when trying to parse a JSON file. Can someone explain the reason behind this error? Additionally, could you provide guidance on how to properly extract va ...

Looking to transfer a multimap from Java to JavaScript using JSON

Seeking advice on the most effective way to transfer multimap values from Java to JavaScript in JSON format. In addition to utilizing an object with a key field and an ArrayList, are there alternative methods I could consider for sending multimap values ...

Using React hooks to control the throttle of useLayoutEffect

I am working on a code snippet that uses useLayoutEffect to attach an event listener for window resize events. I want to enhance it by adding a throttle of 1000ms, so that handleCanvasResize is only called once per second. Can anyone advise on the appropr ...

utilizing spark streaming to produce json results without encountering deprecation warnings

Here is a code snippet where the df5 dataframe successfully prints json data but isStream is false and it's deprecated in Spark 2.2.0. I attempted another approach in the last two lines of code to handle this, however, it fails to read json correctly. ...

Retrieve the .blob file stored on your device

While working on crafting a birthday gift for a friend, I came across an IPA file which I unzipped, only to discover that the picture assets I needed were packed inside a .blob file. While analyzing the hex representation of the file, it appears that the i ...

Javascript - Displaying data retrieved from an external API with JSON

Seeking advice on how to effectively attach JSON values obtained from xhr.response to HTML labels. Any suggestions are appreciated. Thank you. On a different note, does anyone have recommendations for websites that provide concise explanations of basic JS ...

What is the correct way to assign a $scope variable after a successful ajax call?

Currently, I am working with Symfony and AngularJs 1.6.8 along with Symfony 3.4. Below is the configuration setup that I have: base.html.twig <html lang="en" data-ng-app="CeocApp" ng-controller="CeocController"> //css for the app <link id="ng ...

Show and hide a division based on the status of a checkbox

I have a specific requirement regarding authentication modes. When selecting a single factor, only one type of authentication mode can be chosen at a time and the corresponding div will be displayed. However, when selecting multiple factors, I should be ab ...

Using Formik: When the initial value is changed, the props.value will be updated

After the initial props are updated, it is important to also update the values in the forms accordingly. export default withFormik({ mapPropsToValues: (props: Props) => { return ( { id: props.initialData.id, ...

Managing toggles for save and edit buttons in Vue - a comprehensive guide

I am currently working on a Vue 'app' within a larger Django application as a means to enhance my understanding of Vue. My objective is to create unique forms that can be edited independently. I have been experimenting with this for some time n ...

Chrome browser exhibits a phenomenon where the Bootstrap modal will erroneously print the same page multiple times based on the

When I open a modal, there's a print button inside it. I've researched solutions provided here and here to enable printing of Bootstrap modals, but I'm encountering a Chrome-specific bug. The issue doesn't occur in Safari, Firefox, or E ...

Undefined Response Error when Utilizing Dropzone for File Upload in Express

I am currently in the process of setting up a basic image upload demonstration using Dropzone and Express. Here is what my form looks like: <form id="ul-widget" action="/fileupload" class="dropzone" enctype="multipart/form-data"> <div class="fal ...

When navigating to a different tab, the v-if directive does not function correctly

I am in the process of developing a straightforward listing system that presents a list of items for various platforms, with each platform accessible through a separate tab. The logic for switching tabs has been implemented using VueJS from scratch. Overv ...

Parsing JSON data into nested C# objects

Note: Just to clarify, I do not have control over the JSON structure, and I understand that ideally my C# object should align with the JSON format. My question isn't about why the deserialization is not working as expected; rather, I am wondering if t ...

Handling loud JSON responses with Codable

My understanding of Codable is quite clear. To illustrate, consider the following simple example: [ { "id": 1, "name": "Paul", "photo": { "id": 48, " ...

Accessing Wordpress REST API securely with Xamarin Forms using Username and Password information

Is there a method to access the username and password of a specific user using the Wordpress API? It appears that Wordpress has designated the password field as WRITE-ONLY in their API documentation. Using POSTMAN, I am able to retrieve the user's d ...

There seems to be a glitch in my JavaScript for loop as it is not iterating for the correct amount that it should

It seems like my for loop is not always iterating 7 times as intended. Sometimes it runs with 5 iterations, other times with 4 or 3. This is the JavaScript code I am using: var start = new Date().getTime(); var end = new Date().getTime(); function timeT ...

Leveraging jq for extracting and displaying key value pairs enclosed in quotation marks

I need help extracting specific key/value pairs from a file. The content of the file is shown below: { "Job": { "Name": "sample_job", "Description": "", "Role": "a ...

Identifying whether a Alphabet or a Digit has been Pressed - JavaScript

I understand that it is possible to detect if a key has been pressed and identify which key was pressed using JavaScript. In order to check if a key is down or pressed, jQuery can be utilized with ease: $( "#some id" ).keydown(function() or $( "#m" ). ...