Introducing CrudHunt:Open-source Full-stack CRUDs for Next.js by KeenThemes
Browse CrudHunt

Quick Search Server Side Integration


Hi,

The Metronic HTML Quick Search feature is initialized in core/html/src/js/layout/search.js script and it can be integrated with
a server-side AJAX request by replacing the demo process function with an actual search process function:


// Private functions
var processs = function(search) {
// Hide recently viewed list
mainElement.classList.add("d-none");

// Search process
$.ajax({
url: "search.php",
success: function(result) {
if (result.length > 0) {
// Put results
resultsElement.innerHTML = result;
// Show results
resultsElement.classList.remove("d-none");
// Hide empty message
emptyElement.classList.add("d-none");
} else {
// Hide results
resultsElement.classList.add("d-none");
// Show empty message
emptyElement.classList.remove("d-none");
}

// Complete search
search.complete();
}
});
}


The server-side script should return the search in HTML format by following the example search results in the Metronic demo.

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (0)