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

  • SEARCH
  • Home
  • 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 8833505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:47:42+00:00 2026-06-14T08:47:42+00:00

I am currently working on a small web application which includes a calendar displaying

  • 0

I am currently working on a small web application which includes a calendar displaying its entries. When the page gets loaded, the calendar gets generated through PHP.

On the same page, there is a form which allows one to edit the entries. The command to change gets sent by AJAX, and then the calendar has to be reloaded in some way.

What I am wondering about currently is the following:

I have two possibilities of updating the Calendar through AJAX.

  • One is to send the Calendar’s HTML Markup anew, whether it means reloading the entire calendar or the element of the calendar entry.
    This is probably not optimal, since it requires quite a bit of (raw) data sent through the AJAX call.
    On the other side, all it requires is for me to call the same PHP function which generates the markup again, return that and then replace the DOM Element on the clientside, so neccesary work is roughly 5 lines of code.
    This is the way I am currently using since it feels “easier”.
  • The other is to send the Data of the new Calendar entry JSON encoded, and then make the neccesary changes through a javascript function into the existing markup.
    This also feels not optimal, since I would have to use a lot knowledge of the markup twice: Once in the PHP code and once in the JS Code. I can see this redundant code causing problems as soon as the markup would change in any way.
    It also feels like a more ‘complicated’ solution, which includes easily 4-5 as much code considering I have to manipulate a good amount of fields (roughly 10+).
    On the other hand, a lot less data gets transmitted since only the content gets sent.

Which is the better solution? Am I missing a third (or even fourth) option?

  • 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-14T08:47:44+00:00Added an answer on June 14, 2026 at 8:47 am

    The second option doesn’t necessarily need to involve redundancy in your code.

    Your position is that it would do because you’re rendering the calendar HTML in PHP on initial page load, and you want to avoid duplicating that logic in Javascript.

    The way to avoid that is to put the calendar rendering entirely Javascript, and always send the calendar data as JSON from your PHP code.

    On initial page load, this would mean that the PHP program supplies an initial set of data for the calendar, which is then populated by a Javascript initialisation function (eg $(document).ready() if you’re using jQuery).

    This solution means that your code uses a consistent Javascript-based rendering in all cases.

    Of course, your first solution also means a consistent codebase doing the rendering, so both options work just fine from that angle. So if that’s the criteria, then there’s very little to pick between them. Obviously if you have option one coded up already, then that’s a clear winner over option two, unless you have a good cause to switch to Javascript. But other criteria that might come into play could include the possibility of rendering something else using the same JSON object, using it to populate an existing third-party Javascript date control, or providing it as an API for third parties. For these cases, JSON is a clear winner, because it provides more flexibility.

    So I guess it depends on you, and what’s important to you. But I guess the main point I’m making is that both options are possible without duplicating code.

    Hope that helps.

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

Sidebar

Related Questions

I am currently working on a web app with a small web page on
Working on a small web application, I have a user table in which user
I'm working on web application which, among other things, needs to save small file
I'm working on a Python web application in which I have some small modules
I'm currently building a small web application that includes a fair amount of JavaScript.
I'm currently working on a small web application using Visual Studio 2008 Express. I'm
I’m currently working on a small web app that allows people to search for
I am currently working on a small sponsorship application(PHP/MySql) for my personal blog, and
I'm working at a small company and we are developing a web application. With
Currently I am working on small application in asp.net mvc. It is a some

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.