behzad razzaqi
behzad razzaqi

Reputation: 107

Get Sql server data without refresh page

I write program in Asp.Net 4.0 this:

  1. client send json to server
  2. Http Handler get this Json and save into sql server table
  3. My page refresh the page with javascript code per 5 second
  4. in page show the client send data!

But I want delete step 3 and replace with this method:

Without refresh the page my page read sql server table and show in gridview

For example in Facebook page when the user comment on my post, page without refresh show this comment, how can i solve this problem?

Upvotes: 1

Views: 954

Answers (1)

Arindam Nayak
Arindam Nayak

Reputation: 7462

You have couple of options here.

  1. Use Setinterval in javascript and periodically make ajax call to handler to fetch data and render in page. E.g. - http://www.w3schools.com/jsref/met_win_setinterval.asp
  2. Use websocket ( say SignalR ) , that will use HTML5 websocket (depending on browser compatibility) to fetch data and broadcast that data to all connected browsers. -http://www.asp.net/signalr/overview/getting-started/introduction-to-signalr.

Second, option is good one, as this has other fallback methods, such as long polling, server sent event, ajax long polling ( option#1) etc.. Please read details on from that link.

Upvotes: 1

Related Questions