"; } $(".div-predic-search").css("display", "block"); $(".div-predic-search").html(Resulthtml); }, error: function (xhr, status, error) { if (xhr.status === 302 && !predicsearchRetried302) { console.log("Error 302 occurred in ajax request, retrying..."); predicsearchRetried302 = true; predicsearchAjaxRequest("Predicsearch", DataObj, guid); } else { console.log("Error occurred in ajax request:", error); } } }); // return fetch('/your-endpoint', { // method: 'POST', // headers: { // 'Content-Type': 'application/json', // 'RequestVerificationToken': token // }, // body: JSON.stringify({ /* your data here */ }) // }); } else { throw new Error('Failed to retrieve anti-forgery token'); } }) // .then(response => { // if (response.ok) { // console.log('Data sent successfully'); // } else { // console.error('Error sending data:', response.statusText); // } // }) .catch(error => { console.error('Error :', error); }); } var textsearchRetried302 = false; function textsearchAjaxRequest(PostAction, DataObj, guid) { getAntiForgeryToken() .then(token => { if (token) { $.ajax({ type: "POST", url: "/RootsMenu/Textsearch?guid=" + guid, beforeSend: function (xhr) { xhr.setRequestHeader('X-CSRF-Token', token) }, dataType: 'json', contentType: 'application/json; charset=utf-8', //headers: { "RequestVerificationToken": "CfDJ8Chs-6hAXD5Nn6kHTAu16ezqCjnOpys06Xc1IHU2em7rBNF9S2qLLsUauSuDTIZQ4PxhE0ezKqk-4ovC7_-zJl5wLnsl11ygk8KVl24pGTwrvJJZ-YvOdnwg_U5Ep1g1dwG34cYUVMpMxfaYiRXCLJk" }, data: JSON.stringify(Object.assign({}, DataObj, { guid: guid })), success: function (data) { //console.log("result = " + JSON.stringify(data)); //hassearch(); //เอา json โยนเป็น result html var Resulthtml = ""; var Query = data.query; //คำค้นหา var CurrentPage = data.currentPage; //หน้าปัจจุบัน var PrePage = CurrentPage - 1; var NextPage = CurrentPage + 1; //var gethdlang = $("#hdlang").val(); var gethdlang = '/th'; //var Prename = previous; //var Nextname = next; //console.log("C:" + CurrentPage); //console.log("P:" + PrePage); //console.log("N:" + NextPage); //console.log("L:" + gethdlang); var numberOfPages = data.numberOfPages; //หน้าทั้งหมด var allItems = data.allItems; //จำนวนที่เจอทั้งหมด ////console.log("JSON count :"+data.items.length) $(".no-result-list").hide(); ////console.log("data.items.length = ", data.items.length) if (CurrentPage === undefined || data.items.length === 0) { $(".no-results").css("display", "block"); $(".result-list").css("display", "none"); $(".results").css("display", "none"); //$("#noResultInputText").text($("#hdtxtSearch").val()); var searchKeyword = $("#hdtxtSearch").val(); var searchNoResultStatement = '"\u0E1C\u0E25\u0E01\u0E32\u0E23\u0E04\u0E49\u0E19\u0E2B\u0E32 \u003Cstrong\u003E\u0022{{keyword}}\u0022\u003C/strong\u003E \u0E44\u0E21\u0E48\u0E1B\u0E23\u0E32\u0E01\u0E0E\u0E41\u0E15\u0E48\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E43\u0E14"'; searchNoResultStatement = searchNoResultStatement.replace("{{keyword}}", searchKeyword); var text = searchNoResultStatement if (text.charAt(0) === '"') text = text.substring(1); if (text.charAt(text.length - 1) === '"') text = text.substring(0, text.length - 1); $("#noResultInputText").html(text); } else { for (var i = 0; i < data.items.length; i++) { //เอา item ไปวน Resulthtml += "

" + data.items[i].title + "

" + data.items[i].content + "

"; } $(".results").css("display", "block"); $(".result-list").css("display", "block"); $(".no-results").css("display", "none"); $(".search-result .results").addClass("active") $("#divSearchResult").html(Resulthtml); $(".div-predic-search").css("display", "none"); //วนวาด Pages var ResulthtmlPage = ""; ResulthtmlPage += "
" // ตรวจสอบว่าไม่ได้อยู่ที่หน้าแรก if (CurrentPage > 1) { ResulthtmlPage += "
  • "; } var pagesToShow = 10; // จำนวนหน้าที่ต้องการแสดง var startPage = Math.max(1, CurrentPage - Math.floor(pagesToShow / 2)); var endPage = Math.min(numberOfPages, startPage + pagesToShow - 1); for (var j = startPage; j <= endPage; j++) { if (j == CurrentPage) { ResulthtmlPage += "
  • " + j + "
  • "; } else { ResulthtmlPage += "
  • " + j + "
  • "; } } // ตรวจสอบว่าไม่ได้อยู่ที่หน้าสุดท้าย if (CurrentPage < numberOfPages) { ResulthtmlPage += "
  • "; } ResulthtmlPage += "" $("#divSearchPageResult").html(ResulthtmlPage); $("#searchItems").html(allItems); } }, error: function (xhr, status, error) { if (xhr.status === 302 && !textsearchRetried302) { console.log("Error 302 occurred in ajax request, retrying..."); textsearchRetried302 = true; textsearchAjaxRequest(PostAction, DataObj, guid); } else { console.log("Error occurred in ajax request:", error); } } }); // return fetch('/your-endpoint', { // method: 'POST', // headers: { // 'Content-Type': 'application/json', // 'RequestVerificationToken': token // }, // body: JSON.stringify({ /* your data here */ }) // }); } else { throw new Error('Failed to retrieve anti-forgery token'); } }) // .then(response => { // if (response.ok) { // console.log('Data sent successfully'); // } else { // console.error('Error sending data:', response.statusText); // } // }) .catch(error => { console.error('Error :', error); }); } function SearchPage(type, pid) { var S_searchtext = $('input#txtSearch').val(); //console.log(pid); if (type != "") { var getlocation = window.location.origin + window.location.pathname; //console.log(getlocation); if (S_searchtext != false) { var SS_page = 1; if (pid != "") { SS_page = pid; } //url = getlocation + "?searchtext=" + S_searchtext + "&page=" + SS_page; //console.log(url); //window.location.href = url; var Obj = { searchText: S_searchtext, page: SS_page }; CallAjaxSearch("Textsearch", Obj); } } } var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } return false; };

    Sorry, we cannot find

    the page you are looking for!

     

    ขออภัยค่ะ ไม่พบหน้าที่ท่านต้องการ

     

    กลับสู่หน้าหลัก

    " + data.items[i].content + ""; } $(".results").css("display", "block"); $(".result-list").css("display", "block"); $(".no-results").css("display", "none"); $(".search-result .results").addClass("active") $("#divSearchResult").html(Resulthtml); $(".div-predic-search").css("display", "none"); //วนวาด Pages var ResulthtmlPage = ""; ResulthtmlPage += "

    " // ตรวจสอบว่าไม่ได้อยู่ที่หน้าแรก if (CurrentPage > 1) { ResulthtmlPage += "
  • " + j + ""; } else { ResulthtmlPage += "
  • " + j + ""; } } // ตรวจสอบว่าไม่ได้อยู่ที่หน้าสุดท้าย if (CurrentPage < numberOfPages) { ResulthtmlPage += "