最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - Page is loading after submit before the file is processed

programmeradmin2浏览0评论

I have built a user import page that imports via csv file upload. The issue I am having is that the page is loading before all of the rows (user information) is finished processing/ inserting users. It works fine if there is 1 or 2 users/ rows in csv but beyond that it does not complete the job.

Is there a way to delay the page load until the process of importing the users from the csv file is completed?

The use case goes like this. A user goes to the import page, browses files (csv) then clicks submit. After clicking the submit, a function kicks off that processes each row in the csv and imports user into wordpress. The csv file could have hundreds of rows or just a handful. The page will keep loading until the process is complete. Once complete the page loads and has an output(log) of all of the users that were imported.

The part that I am stuck on is giving enough time for the process to finish before the page is loaded.

I have built a user import page that imports via csv file upload. The issue I am having is that the page is loading before all of the rows (user information) is finished processing/ inserting users. It works fine if there is 1 or 2 users/ rows in csv but beyond that it does not complete the job.

Is there a way to delay the page load until the process of importing the users from the csv file is completed?

The use case goes like this. A user goes to the import page, browses files (csv) then clicks submit. After clicking the submit, a function kicks off that processes each row in the csv and imports user into wordpress. The csv file could have hundreds of rows or just a handful. The page will keep loading until the process is complete. Once complete the page loads and has an output(log) of all of the users that were imported.

The part that I am stuck on is giving enough time for the process to finish before the page is loaded.

Share Improve this question asked Jun 10, 2019 at 22:21 graygray 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

It sounds like you're running into the server's timeout setting (usually between 30 and 60 seconds). Once you hit that point, the page stops loading and returns as much as has been processed. In your case, I would try loading portions of the csv as pages just like paging through posts in WordPress. If you need to load the full csv, try loading it in dynamically with AJAX requests until the fill csv is loaded.

If you're doing any processing on the csv, I would do these in chunks as well to prevent hitting this timeout. You could do this with scheduled tasks, AJAX requests, or even via the command line, if that's a possibility.

发布评论

评论列表(0)

  1. 暂无评论