# JQuery

For example, using **jQuery** [**(JSFiddle)**](https://jsfiddle.net/yvbf4cw1/)

```
//Example of getting entries using jQuery

//Replace parameters with your own
var params = {
  grant_type: 'client_credentials',
  client_id: 2,
  client_secret: 'QowjYIFrWbzLEwttXzuTnb20OPbRWwlPlaNLQ6VW'
}

//perform Ajax request to get token
$.ajax({
  url: 'https://five.epicollect.net/api/oauth/token',
  type: 'POST',
  contentType: 'application/vnd.api+json',
  data: JSON.stringify(params),
  success: function(response) {
    console.log(JSON.stringify(response));
    //the token is valid for 2 hours, let's get the entries
    _getEntries(response.access_token);
  },
  error: function(xhr, status, error) {
    console.log(xhr.responseText);
  }
});

//get the entries, passing token for authorisation
//ec5-api-test is the project slug
function _getEntries(token) {
  $.ajax({
    url: 'https://five.epicollect.net/api/export/entries/ec5-api-test',
    type: 'GET',
    contentType: 'application/vnd.api+json',
    headers: {
      Authorization: 'Bearer ' + token
    },
    success: function(response) {
      //Here are the entries, just log them for now ;)
      console.log(JSON.stringify(response));

      //do what you want with the response (entries)
      // ...
    },
    error: function(xhr, status, error) {
      console.log(xhr.responseText);
    }
  });
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.epicollect.net/api-authentication/access-resources/jquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
