• Register
0 votes
589 views

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

Please log in or register to answer this question.

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();
    console.log(states);
}
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 8 views
8 views
Problem: I need to append this div to another div, but it gives me this error : Syntaxerror: json.parse: unexpected character at line 1 column 2 of the json data Any ideas?
asked Mar 22 ummesalma 24.5k points
0 votes
1 answer 23 views
23 views
Problem: I have a script that runs a few times a second and pulls the data and the webpage loads it. The problem is, after about 20+ times of the server reading the json file, eventually it will throw this error. Syntaxerror: json.parse: unexpected end of data at line 1 column 1 of the json data What exactly went wrong here?
asked Mar 22 ummesalma 24.5k points
0 votes
1 answer 3 views
3 views
Problem: Please can anyone tell me the right procedure to do it? How to get json data in jquery?
asked 5 days ago Ifra 24.4k points
0 votes
1 answer 9 views
9 views
Problem: I want to fetch my Json file in react js, for this, I am using fetch. But it shows an error Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
asked Mar 16 ummesalma 24.5k points
0 votes
1 answer 7 views
7 views
Problem: After creatuing an application which is not loaded with much information except Signup but I got this error&raquo; Syntaxerror unexpected token o at object.parse native.
asked Mar 23 PkGuy 13.1k points
0 votes
1 answer 12 views
12 views
Problem: In a React app component that handles Facebook-like content feeds, I am running into an error: Feed.js:94 undefined "parsererror" "SyntaxError: Unexpected token < in JSON at position 0 Thanks
asked Mar 22 ummesalma 24.5k points
0 votes
1 answer 256 views
256 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 8 views
8 views
Problem: I am getting the error SyntaxError: Unexpected token C in JSON at position 0. I am also assuming that the error is related to the request.
asked Mar 16 ummesalma 24.5k points
1 vote
1 answer 15 views
15 views
Problem: I am getting a weird error which may unable me app not to appear images on local host . Manifest: line: 1, column: 1, syntax error.
asked Mar 30 PkGuy 13.1k points
0 votes
1 answer 10 views
10 views
Problem: SyntaxError: Unexpected token o in JSON at position 1 How can I extract the user list to a new variable?
asked Mar 16 ummesalma 24.5k points