jsduniya
jsduniya

Reputation: 2474

How to Refresh element in Cakephp

Ex:Site Explanation:


  1. Two super admin SA1 SA2
  2. Update button will apear on dashboard when they log into the admin side.

Needed


When SA1 click on Update Button it will take 15 minutes to complete the task, Consider while the process in progress,& SA2 logs in he should come to know SA1 already clicked on update button, until unless it finish off, SA2 can not click on it.


What I did


Created table 'button_status' [id, status('complete','incomplete')] whenever SA1 or SA2 clicks on update button i am inserting new record with status as'incomplete' value, until that i am showing process in progress with loading image and disabled the update button for both SA1 & SA2, once process get finishes after 10 mints i am updating status for last record to 'complete'. and removing loading image and making update button enable.
Everything is Working fine, problem is loading image or disabled button for other admin who did not clicked on update button, i am not able remove it as for that i need to refresh the page. Is there any ways to show completed automatically whenever for other admin without refreshing the page after 'complete' status updated in db ?

Upvotes: 4

Views: 956

Answers (1)

icebreaker
icebreaker

Reputation: 1274

There are three ways of getting it straight.

AJAX Comet

This involves client-server implementation where client responds to events on server. More on AJAX Comet. One of solution I have used is meteor server. It was relatively simple to setup, but you need access server to configure it your way. It has been discontinued though.

Pros

  • You update page only when there is change. Thus taking off load of your server.
  • Little or no latency

Cons

  • Configuration of server-client
  • Time consuming implementation

Timed Polling

You can poll your server once a period of time for changes. You ask custom script to return locked records in JSON or XML. Based on that you update button statuses with javascript. Deeper it is discussed Reload AJAX data every X minutes/seconds, jQuery

Pros

  • Easy and fast implementation

Cons

  • Adds additional load on server
  • Still has some latency

Leave it as is

If that is administrative interface and frustration on clicking already locked record is not big deal, I would leave it as it is.

One more

I found interesting solution for live data applications http://meteor.com/, their SO tag, but currently they have only mongodb support.

Upvotes: 1

Related Questions