Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created April 10, 2017 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mgibbs189/59a0a050e9bd1ba0aedadb2e8c565cc5 to your computer and use it in GitHub Desktop.
Save mgibbs189/59a0a050e9bd1ba0aedadb2e8c565cc5 to your computer and use it in GitHub Desktop.
FacetWP - REST API - ajax example
<script>
(function($) {
$(function() {
var data = {
'facets': {
'make': ['audi'],
'vehicle_type': []
},
'query_args': {
'post_type': 'cars',
'posts_per_page': 4,
'paged': 1
},
};
$.ajax({
type: 'POST',
url: 'http://wp.dev/wp-json/facetwp/v1/fetch',
data: { data: JSON.stringify(data) },
success: function(response) {
console.log(response);
}
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment