• Register
0 votes
864 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.

7.5k 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.

38.6k points

Related questions

0 votes
1 answer 35 views
35 views
Problem: Is there somebody who can assist: Syntax error: JSON.parse: unexpected character at line 1 column 1 of the JSON data?
asked Jun 13 Nahil 128k points
0 votes
1 answer 250 views
250 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 29.1k points
0 votes
1 answer 477 views
477 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 29.1k points
0 votes
1 answer 7 views
7 views
Problem: System error3: syntaxerror: unexpected token < in json at position 0.
asked Jul 3 Rada Gracelynn 104k points
0 votes
1 answer 14 views
14 views
Problem: Please can anyone tell me the right procedure to do it? How to get json data in jquery?
asked Apr 7 Ifra 43.4k points
0 votes
1 answer 27 views
27 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 29.1k points
0 votes
1 answer 19 views
19 views
Problem: Syntaxerror: unexpected token o in json at position 1
asked Jun 26 Chi Omega 168k points
0 votes
1 answer 21 views
21 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 25.9k points
0 votes
1 answer 25 views
25 views
Problem: Syntaxerror unexpected token in json at position 0
asked Jun 29 Chi Omega 168k points
0 votes
1 answer 52 views
52 views
Problem: I have no idea how to solve this, someone help >Syntaxerror: unexpected token u in json at position 0
asked May 16 Chi Omega 168k points