• Register
0 votes

Problem :

I have spent over the 10 hours in finding the exception or the special character to find in the code but I am unable to find it. I have already checked every similar messages in here.

I am facing below error:

Syntaxerror: json.parse: unexpected character at line 1 column 1 of the json data

I am just sending the form with the magnific popup. Firstly I am using the inline popup to open my form after that I am sending all the inputs to the  main.js to validate it.

So, I am just looking for the third-eye.

6 5 3
7,540 points

1 Answer

0 votes

Solution :

I had faced the same Error in the past while I was trying to fetch data from the json file.

"SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

So, I just checked my path of the json file which was found to be incorrect,

const mysearch = document.getElementById("mysearch");
const mymatchList = document.getElementById("mymatch-list");
//search the json data and filter
const mysearchStates = async mysearchText => {
    const myres = await fetch('../state.json');
    const mystates = await myres.json();
mysearch.addEventListener('input', () => mysearchStates(mysearch.value));

That’s why I simply changed the path of my file as below:

const myres = await fetch('./state.json');

& to my surprise it gave me the array back as a result. I hope this resolved your issue.

9 7 4
38,600 points

Related questions

0 votes
1 answer 45 views
Problem: Recently I have joined the angular2 project. But now I am stuck with below listed errors. The errors occurred if I tried to send my JSON objects to my backend. It may be due a parsing of my JSON objects. I am very new to angualar so unable to find ... (core.umd.js:3971) at ZoneDelegate.invokeTask (zone.js:274) at Zone.runTask (zone.js:151) at XMLHttpRequest.ZoneTask.invoke (zone.js:345)
asked Aug 5 Raphael Pacheco 4.9k points
0 votes
1 answer 13 views
Problem: I want to create the search box for the states, districts and villages but because of some unknown reason to me I am just unable to fetch my data into the combobox. Please find my code as shown below: My HTML code: <div class="dummy__item">  < ... below task: Dynamically populate a select element from json data with jquery . I am looking for the expert in Javascript , Jquery and Json.
asked Jul 2 Raphael Pacheco 4.9k points
0 votes
1 answer 10 views
We had a online based survey company. We survey the market on the basis of user&rsquo;s opinion. we need to store the user&rsquo;s data and utilize the text data input. How can we do this using javascript ?
asked Sep 15 Daniel Anderson 4k points