$(document).ready(function(){ getCategory() getLatestBlog() $('#search-blog-form').submit(function(e){ e.preventDefault() SEARCH = $('#search-blog').val() console.log("search:", SEARCH) $('#blog-list').html(`
`) $('#blog-infinity-scroll').html("") getBlogList() }) }) function getCategory(){ $.ajax({ async: true, url: `${BLOG_CATEGORY_API_URL}all-and-blog-total`, type: 'GET', error: function(res) { const response = JSON.parse(res.responseText) }, success: function(res) { renderCategory(res.data) } }); } function getLatestBlog(){ $.ajax({ async: true, url: `${BLOG_API_URL}?page_number=0&page_size=5&status=PUBLISH`, type: 'GET', error: function(res) { const response = JSON.parse(res.responseText) }, success: function(res) { renderLatestBlog(res.data) } }); } function renderCategory(categories){ let categoriesHtml = `` categories.forEach(category => { let itemHtml = `