Sometime we required to render the views through ajax in your desirable place in you web page. Here is a views/ajax API snippet to call the views with some arguments and views details.
Create views
Create a views by using Views UI and Enable Use Ajax
Grab required parameter's values
Collect following parameters from Views UI
- view_name like article_list
- view_display_id like block_1/page_1
- view_args like 1,2 (if you use Content ID in Contextual filters)
Add custom js into the Drupal module via *.libraries.yml
Refer if you don't know how to add libraries.yml - Adding assets (CSS, JS) to a Drupal module via *.libraries.yml
Add below snippet to custom_module/custom_module.libraries.yml