Проблемы с ajax запросом. Выдает Unexpected end of JSON input

Начал увлекаться вебом недавно, делал пагинацию, но столкнулся с такой проблемой: введите сюда описание изображения

let pageVal = 1
getAllPosts(pageVal)
function getAllPosts(page){
    $.ajax({
        url: `get.php?page=${page}`
    }).done(function(res){
        res=JSON.parse(res)
        showAllPosts(res.posts)
        showAllPages(res.totalPages)
    })
}

function showAllPosts(posts){
    let output = ''
    for(const post of posts){
        output += `
        <div class='col-sm-4 mb-5'>
            <div class='card'>
                <div class='card-body'>
                    <h5 class='card-title'>${post.title}</h5>
                    <p class='card-text'>${post.description}</p>
                    <p class='card-text'>${post.views}</p>
                    <a href='detail.php?id=${post.id}' class='btn btn-primary'>Go somewhere</a>
                    <a href='edit.php?id=${post.id}' class='btn btn-info'>Edit</a>
                    <a href='delete.php?id=${post.id}' class='btn btn-danger'>Delete</a>
                    
                </div>
            </div>
        </div>
        `
    }
    $('#all-posts').html(output)
}
function showAllPages(pages){
    let output = ''
    for(let i=1;i<=pages;i++){
        output+=`
        <li class='page-item'><a class='page-link' href='#' onclick="showNext(${i})">${i}</a></li>
        `
    }
    $('#all-pages').html(output)
}
function showNext(page){
    pageVal = page
    getAllPosts(pageVal)
}


Ответы (1 шт):

Автор решения: vieri

Решил проблему, проблема была в get.php, спасибо всем

→ Ссылка