Support the ongoing development of Laravel.io →
Views Blade Eloquent
Last updated 2 years ago.
0

I don't know enough about Laravel to answer with authority on Laravel, but I suspect this is not a Laravel issue but an architecture / process issue.

My solution would be to load first before doing the heavy lifting, then load the required data using AJAX.

You can either return the results as JSON, and use JavaScript to populate your page, or just return a rendered view and insert that directly.

Last updated 9 years ago.
0

davestewart said:

I don't know enough about Laravel to answer with authority on Laravel, but I suspect this is not a Laravel issue but an architecture / process issue.

My solution would be to load first before doing the heavy lifting, then load the required data using AJAX.

You can either return the results as JSON, and use JavaScript to populate your page, or just return a rendered view and insert that directly.

How do I do that though?

0

Well, instead of running all the DB setup in your index controller:

Create a new route/method

  1. Set up a new route, e.g. 'clans/load'
  2. Route this to ClansController@load
  3. In the ClansController load() method, put all the DB code which is taking the time to load
  4. Return the results, in JSON or HTML

In your index method:

  1. Return just the basic HTML page

In your HTML page:

  1. Show the loading animation
  2. Using jQuery, at the end of the page (or on a page ready function) call the 'settings/load' endpoint
  3. When the results are returned, stop the animation and inject your content

Something like this:

$.get('clans/load', function(html){
    $('#content').html(html);
});

You could even pass variables via the route to the load() method if you wanted, such as page, count, etc. and wire these to links in the HTML page.

Loads of advice out there on jQuery. If you don't know it, now is the time to learn!

Last updated 9 years ago.
0

I still don't get it... :/

0

Probably time to change jobs then.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

shivampaw shivampaw Joined 30 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.