Call AJAX callback on page load I've been reading the whole day but I cannot find a complete example for a basic AJAX call on load page.

I followed this tutorial: and this example: 

I was able to register the callback, controller and commands but the only way to trigger the ajax call is creating a link and is triggered on click event (as the example does)

&lt;a class="use-ajax" href="/ajax/nojs/ajaxload"&gt;XXX&lt;/a&gt;


I need to trigger that ajax call but when the page is loaded, is there any way? 

Thanks
Funny how those tutorials did not mention Drupal behaviors, which will trigger once the page is loaded. This is a good tutorial on them (Drupal 7, but same principles apply).

Basically all you should do is call your callback function from a behavior to get the same effect as jQuery's document ready callbacks.

Drupal.behaviors.myModule = {
  attach: function (context, settings) {
    // Call callback here.
  }
};


And while you are at it, I recommend reading up on behaviors as they help to streamline your javascripts and keeps them in closed scopes.