Answers.Body: <p>After leaving this issue for a day I found an article referring to the docs
  <a href="https://docs.craftcms.com/api/v3/craft-web-twig-variables-paginate.html#method-setbasepath" rel="nofollow noreferrer">setBasePath</a></p>
  <pre><code>{% paginate queryLeden as pageInfo, pageEntries %}
  {% if craft.app.request.isAjax %}
      {% do pageInfo.setBasePath('YOURBASEURL') %}
  {% endif %}
  </code></pre>
  <p>Hope this helps someone else :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-01T21:38:41.017Z
Answers.LastActivityDate: 2021-12-01T21:38:41.017Z
Answers.UserDisplayName: Kevon
Body: <p>I'm loading a paginate via <code>Craft::$app-&gt;getView()-&gt;renderTemplate()</code>, this is being executed within a controller. But my pageInfo.nextUrl is now the url of my controller (/actions/controllername/default/p2) is there a way to fix this or am i doing something terribly wrong here?</p>
  <p>The complete routing is:</p>
  <ol>
  <li>/paginationurl</li>
  <li>fetching new pagination lists with ajax with the help of a controller (templates are _private)</li>
  <li>url output is of the pageInfo is now the action url of this controller</li>
  </ol>
  
Tags: <templating><ajax><modules><controller><pagination>
Title: Craft 3 paginate not working when fetched with a controller
ThreadText: # Craft 3 paginate not working when fetched with a controller
  
  (Asked by: username_0 on 2021-12-01)
  
  I'm loading a paginate via `Craft::$app->getView()->renderTemplate()`, this is being executed within a controller. But my pageInfo.nextUrl is now the url of my controller (/actions/controllername/default/p2) is there a way to fix this or am i doing something terribly wrong here?
  
  The complete routing is:
  
  1. /paginationurl
  2. fetching new pagination lists with ajax with the help of a controller (templates are \_private)
  3. url output is of the pageInfo is now the action url of this controller
  
  **Tags:** templating, ajax, modules, controller, pagination
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-12-01. Score: 2
  
  After leaving this issue for a day I found an article referring to the docs
  [setBasePath](https://docs.craftcms.com/api/v3/craft-web-twig-variables-paginate.html#method-setbasepath)
  
  ```
  {% paginate queryLeden as pageInfo, pageEntries %}
  {% if craft.app.request.isAjax %}
      {% do pageInfo.setBasePath('YOURBASEURL') %}
  {% endif %}
  
  ```
  
  Hope this helps someone else :)
  
  
  ---
  
  