Answers.Body: <p>Since Craft makes no assumptions about the front-end content of your website, it's 100% up to you on how you want to implement AJAX functionality on your site.  So it wouldn't be any different if you were trying to use AJAX on a simple static page with no CMS managing the content.</p>
  
  <p>For example, a popular method is to use <a href="https://api.jquery.com/jquery.ajax/" rel="nofollow">jQuery's ajax method</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-08T17:14:41.970Z
Answers.LastActivityDate: 2016-08-08T17:14:41.970Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>For search autocomplete functionality, you can use <a href="https://github.com/craftcms/element-api" rel="nofollow noreferrer">Element API</a> plugin. It creates API endpoint that can be queried with ajax and it will return JSON (or any other format) results.</p>
  
  <p>On my blog you will find how to implement search autocomplete functionality this way:
  <a href="http://craftsnippets.com/articles/search-autocomplete-component-for-craft-cms" rel="nofollow noreferrer">http://craftsnippets.com/articles/search-autocomplete-component-for-craft-cms</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-30T10:44:45.913Z
Answers.LastActivityDate: 2019-03-30T10:44:45.913Z
Answers.UserDisplayName: Piotr Pogorzelski
Answers.Body: <p>You'll need to set the X-Requested-With header to XMLHttpRequest.</p>
  
  <pre><code>const response = await fetch(url, {
    headers: {
      'X-Requested-With': 'XMLHttpRequest',
    },
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-15T06:11:46.467Z
Answers.LastActivityDate: 2020-06-15T06:11:46.467Z
Answers.UserDisplayName: Oleg
Body: <p>I want to do an autocomplete search engine on my website. But I don't know how to use Ajax in Craft CMS. How can I set an Ajax function in Craft CMS templating? The search engine must have dynamic auto-complete feature according to title and content.</p>
  
Tags: <ajax>
Title: How can I use Ajax function in Craft CMS?
ThreadText: # How can I use Ajax function in Craft CMS?
  
  (Asked by: username_0 on 2016-08-08)
  
  I want to do an autocomplete search engine on my website. But I don't know how to use Ajax in Craft CMS. How can I set an Ajax function in Craft CMS templating? The search engine must have dynamic auto-complete feature according to title and content.
  
  **Tags:** ajax
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2016-08-08. Score: 4
  
  Since Craft makes no assumptions about the front-end content of your website, it's 100% up to you on how you want to implement AJAX functionality on your site. So it wouldn't be any different if you were trying to use AJAX on a simple static page with no CMS managing the content.
  
  For example, a popular method is to use [jQuery's ajax method](https://api.jquery.com/jquery.ajax/).
  
  
  ---
  
  ### Answer by username_2 on 2019-03-30. Score: 2
  
  For search autocomplete functionality, you can use [Element API](https://github.com/craftcms/element-api) plugin. It creates API endpoint that can be queried with ajax and it will return JSON (or any other format) results.
  
  On my blog you will find how to implement search autocomplete functionality this way:
  <http://craftsnippets.com/articles/search-autocomplete-component-for-craft-cms>
  
  
  ---
  
  ### Answer by username_3 on 2020-06-15. Score: 1
  
  You'll need to set the X-Requested-With header to XMLHttpRequest.
  
  ```
  const response = await fetch(url, {
    headers: {
      'X-Requested-With': 'XMLHttpRequest',
    },
  });
  
  ```
  
  
  ---
  
  