Polling for status of sequential API calls

I am building an application which is a simple form. You place queries in a number of form elements and click submit. This submits a (fairly) large number of API calls to a 3rd party API to create the necessary objects in the third party app, perform them, then return the results to my app. The process takes 5-30 seconds. What I want this to do is render the results in a partial (think SQL IDE, like SSMS or TOAD or whatever - input at top, returns results below). And i would like this partial to refresh after each step in the process and display the status of the task to the user. Currently the app just sits and spins until all of this complex and IO heavy business logic is complete, which is resulting in horrible user experience. So, lets say the steps taken through the 3rd party API are: 1. create widget 2. start widget 3. monitor widget status 4. When complete, return final results to user. What I want to do is have a variable, say @status, which contains the current execution of the above process. "Creating Widget..." etc etc. This displays to the user as the tasks complete. How could i re-render the partial whenever one of these tasks are complete? Should it poll the server? And how would I go about polling a process running serverside without the thread locking until the above steps are complete? Currently, this is not written to a database, and I would like to keep the database out of this as much as possible due to load restrictions. Now, I am aware of different methods of polling to an action (AJAX through jquery), primarily using setinterval/timeout to make calls to a controller action and re-render, but If my API call methods are referenced in that action, it simply waits until it is all done anyway. Any thoughts?

以上就是Polling for status of sequential API calls的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏