简体   繁体   中英

Update content only if data from ajax call has changed

I have an HTML table which is being filled with data that's collected via an AJAX call.

This ajax call is triggered every X seconds.

I only want the table to update if the data received from the AJAX call is different from the existing data within the table.

Any way of achieving this?

You would have to store the data and do comparisons in every AJAX callback.

If your comparison is heavy to compute than generate a hash on the server side and send it to the client with the payload. You would need to store and compare the hash only.

Instead of hammering your sever it would be even better to use SignalR and just push your changes as they happen (if you're .NET). You can find similar frameworks for other platforms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM