I am building a filter function in ajax and php (I am new to ajax). I have an html input like this:
<form>
<input type="text" placeholder="Search" onkeyup="getListSearch(this.value)" name="search_filter">
</form>
The current function getListSearch looks like this
function getListSearch(filter) {
$.ajax({
method : "POST",
url : "www.example.com/includes/content.php",
data : {
search_filter: filter
},
success : function(result) {
$("#list_content").html(result);
}
});
}
This works but loads the whole result, I only want to show the div with class .list_content from content.php.
I tried the below codes
$("#list_content").html($(result).find('.list_content'));
// Tried below also
$("#list_content").load(result + " .list_content");
But no success.
Any help would be appreciated.
2
Answers
Thanks for the response, this worked for me: