0

I currently have a table view that is part of my webpage that displays the top 10 rows of a table in my database. I have a controller in my MVC5 that inserts data into the table and I have another console application that runs on a scheduler, which updates the data in the same table.

originally I was thinking of using signalR to detect changes in the database in order update my table view, but due to lack of experience with signalR and lack of full permissions for the database, I hit some obstacles.

Then I discovered a MUCH MUCH easier 5 line solution, which refreshes my table view every second by using load()

function autoRefresh_div() {
    $("#reload").load(" #reload", function() {
        setTimeout(autoRefresh_div, 1000);
    });
}

It worked absolutely flawless because even my times are getting updated by the second as a side effect. However, I feel like there must be some downside to this method because everything usually has its trade-offs.

I would like to know if this approach is considered bad practice. Thanks!

P.S. the table is only displaying 10 rows atm by selecting the top 10 most recently modified rows and it probably will stay that way.

enter image description here

ygongdev
  • 264
  • 3
  • 19
  • How is that code working? That looks incorrect according to the docs for [`.load()`](http://api.jquery.com/load/) – 4castle Jun 20 '16 at 20:38
  • @4castle Tbh, I'm not exactly sure myself LOL, but I combined the answers from both http://stackoverflow.com/questions/35141442/reload-a-div-via-ajax-immediately-and-then-every-5-seconds and http://stackoverflow.com/questions/17886578/refresh-part-of-page-div – ygongdev Jun 20 '16 at 20:51

0 Answers0