Support » Fixing WordPress » preparing shortcode output before loading page

  • Mostafa Shahiri

    (@mostafadeveloper)


    Hi
    I am trying to create a plugin that displays a csv file as html table. It uses shortcode for creating html table. For small csv files it works fine, but for large csv files, it takes long time to read csv file. I use fgetcsv function for reading csv files. Is there any way to prepare shortcode output before displaying result? I want to read csv file before loading page. Please help me.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you tried calling your functions through ajax? Like call the function, count the rows, when all rows are added to your variable, return.

    Thread Starter Mostafa Shahiri

    (@mostafadeveloper)

    @tugbucket Thanks for your reply. Yes, using ajax improved loading time,but when I try to inject huge numbers of rows via ajax response to the table, browser is stuck and stop working for a few seconds.

    If it does load all the data even after it “hangs” put a loading animation or screen up and when the response comes back remove it and show your data. That way visually it looks fine until its finished. If its massive, like 1k rows plus, you might slso want to use sleep() or something similar so that you dont run out of memory. If its tons of data, the browser will hang while it processes, not realky anything you can do but you csn make the site display that it is working.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘preparing shortcode output before loading page’ is closed to new replies.