Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7847769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:59:52+00:00 2026-06-02T17:59:52+00:00

What is the best way to achieve synchronization between database and web page when

  • 0

What is the best way to achieve synchronization between database and web page when using ajax calls to change the data? To give an example, let’s say I have a form for adding comments and I want this to work asynchronously. Hence I create a JS code that submits that form to a database. What is the best practice to display this new data to the user without having to refresh the page? At the moment I can think of 3 solutions to this problem:

  1. Put JS code in the callback that will process and insert this data to the appropriate element on the page after we receive an ok mesage from the server.

  2. As a response from the server, send all the data that should be displayed in the element and then simply use JS to insert everything.

  3. Kind of a mix between 1 and 2, as a response from the server send only the processed new piece of data and insert it to the appropriate place.

I don’t like the code duplicity in 1, i.e. we have to implement the processing logic twice. I also don’t like the 2. because of the overhead of data that is sent from server. As for 3. I like this approach the most, but there is still some overhead of data sent back and forth. I know these overheads will probably not affect the functioning of the system in most cases, but I am wondering whether there is any other solution to this problem and what is the best practice to make sure the data is in sync?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:59:53+00:00Added an answer on June 2, 2026 at 5:59 pm

    You might want to consider using Models and Collections like how backboneJS does it. It’s sort of a “local copy of the database”. First, your model fetches just a few records for display, like the top 10 things in a todo list. the model has CRUD methods where you can manipulate the data in it.

    Then for your interface, you have separate code for views. these views hook up to the model, do CRUD as well as listen to model data changes which can be from the current module interface or another part of your interface. if one part of the page changes the data, the rest that are hooked on to the same model gets notified. models can be anything, and it may represent one or a combination of tables in the database

    similarly, that model will have an AJAX sync capability. every data modified in it gets reflected to the server via an AJAX call. when that call completes, you notify all hooked interfaces to update accordingly. since the data is contained in the model, you only need to send changes to the server and listen for a success. as for live data from the server, you can create some polling capability in the model to update it’s data. if there’s change, notify all hooked interfaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to achieve the result on this page In other
I've found that using a vector is the best way to achieve what I
What is the best way to achieve application authorization and entitlement in .Net. Earlier
I have always wondered what's the best way to achieve this task. In most
the best way to explain is with example so: this is the model public
The best way I can think of to ask this is by example... In
What is the best way to maintain upgrade scripts between versions of a product?
What is the best way to achieve cross-browser(ff,ie>6,chrome,opera,safari) curved corners on a div. I
What would be the best way to achieve this? I've got a list of
What would be the best way to achieve a human readable number, currently have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.