christian-fei / Simple-Jekyll-Search

A JavaScript library to add search functionality to any Jekyll blog.
https://christian-fei.github.io/Simple-Jekyll-Search/
MIT License
1.34k stars 203 forks source link

Facing issue: SimpleJekyllSearch --- failed to get JSON #165

Closed satheesh-mallow closed 3 years ago

satheesh-mallow commented 3 years ago

@all

I am facing SimpleJekyllSearch --- failed to get JSON issue only in this project. I didn't know why it is happening.

Screenshot 2021-03-15 at 2 24 46 PM

I have also checked the network tab, the file response is 200 but still I am getting above issue.

Screenshot 2021-03-15 at 2 24 59 PM

Code:

<script src="https://unpkg.com/simple-jekyll-search@latest/dest/simple-jekyll-search.min.js"></script>

<input type="text" id="search-input" placeholder="Search blog posts..">
<ul id="results-container"></ul>
<script>
    $(document).ready(function(){
        var sjs = SimpleJekyllSearch({
            searchInput: document.getElementById('search-input'),
            resultsContainer: document.getElementById('results-container'),
            json: 'http://127.0.0.1:4000/search.json'
        })
        });
</script>
christian-fei commented 3 years ago

Hello @satheesh-mallow , you could try to use a relative path for the "/search.json"

            json: 'http://127.0.0.1:4000/search.json'

If you have a public repo or link I can take a quick look.

satheesh-mallow commented 3 years ago

@christian-fei

Have tried that, I have found the issue. There is a unexpected character \ where placed in the json file.