Reputation: 2013
I want to display progress on my screen/page/view just as happens in console. So when i click install button, my "textarea" control should start displaying progress like
connecting to database connection successful running script a.sql running script b.sql operation complete connection closed
Upvotes: 0
Views: 1825
Reputation: 23876
To be able to do this easily, you can use SignalR which simplify all the hassle of which underlying technology to be used based on the version of the browser it will choose the best communication protocol (WebSocket, LongPolling..etc).
Behind SignalR, one of the underlying used technologies is websockets, it doesn't send anything except keep an open full duplex channels between server and client, in case any update in the server it will push this update to the client. most popular sites use websockets for keeping open channels between server and client.
SignalR uses actually websockets however it will downgrade to use long polling for example in case of old browsers that don't support websocket's connection upgrades.
You have the option to use the websockets directly in case you are assured your clients use new browsers.
One last thing Stackoverflow as a big and heavy loaded site uses websockets to update once there is a new answer or comment for example.
Upvotes: 2
Reputation: 17233
The general approach for this is just sending an ajax request every second or so and asking for an update from the server.
<div>
<pre id="status">
</pre>
</div>
setInterval(function () {
$.ajax("/getUpdate?someParam=1234").then(function (result) {
// result is whatever JSON object you send from the server
$("#status").innerText = result.someProp;
});
}, 1000);
It might look something like the above. Note that it's doing a request every second and storing the message from the server in the pre
element.
Upvotes: 1