• 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

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();
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 121 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 16 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 12 views
0 votes
1 answer 17 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, 2020 Daniel Anderson 4k points
0 votes
1 answer 10 views
Problem: I am very new to programming world. I have below HTML code and I want to submit it and save the form data with the help of javascript. <!DOCTYPE html> <html> <head>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width"> ... If I click on the submit button then the above forms data should be saved somewhere for the each and every user who fills and submits the data.
asked Jul 30, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 97 views
Problem Hello Kodlogs I need step by step instructions on how to use jquery ajax and php to fetch data from a mysql database that I have created. I have found certain code snippets but but I am looking for a comprehensive step-by-step example. Thanks in advance
asked Oct 29, 2020 hashq 1.1k points
0 votes
1 answer 24 views
I want to display other data based on dropdown selection in HTML and Jquery.
asked Oct 3, 2020 Daniel Anderson 4k points
0 votes
1 answer 18 views
Problem: How do you send data to a PHP page using jQuery AJAX?
asked Sep 19, 2020 coder101 160 points
1 vote
1 answer 450 views
Problem : I am very beginner to PHP, Jquery and ajax, and I am really going through very hard time while trying to find a solution on a web based platforms which I could use to solve my problem. Currently I am trying to display the data from my database into ... for me also tried to find for the solution online but unable to find any. So looking for expert programmers help who can fix my problem.
asked May 18, 2020 Martin K 6.6k points