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 3843722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:58:43+00:00 2026-05-19T15:58:43+00:00

My projects are becoming more and more JS heavy. The issue is that most

  • 0

My projects are becoming more and more JS heavy. The issue is that most of my data is on the server side (PHP). What are some clean ways for transporting this data over to the client side (code samples for extra brownie points)?

Some ways I am considering – which of these are best?:

1) Use php to “echo” directly to js variables.
2) Use php to write to HTML elements and then use js to retrieve from the dom.
3) Use ajaxcall

Thoughts?

  • 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-05-19T15:58:43+00:00Added an answer on May 19, 2026 at 3:58 pm

    All of those methods are workable. As said, it really depends on the use case.

    1) Use php to “echo” directly to js variables.

    Which is a necessity if you need some data at “initialization time”. If your initial page display depends on some state variable, there’s no way around this method.

    2) Use php to write to HTML elements and then use js to retrieve from the dom.

    I consider this the lazy option. It allows to update data without coding two different ways to retrieve it. Since jQuery provides .load("file.php div.data") you often can reuse existing output templates.

    3) Use ajax calls

    That’s probably the best option for querying. Especially if you need information from the database or poll some status this is the preferred way. Use JSON for returning data, but prefer GET/POST variables for client->server communication.

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

Sidebar

Related Questions

Some of the greatest and most successful open source projects only started becoming more
Some projects are so big that in order to understand for example a function
Most projects now need some form of a database. When someone says database, I
I'm working on a project with Node.js and the server-side code is becoming large
my projects deals with a client / server structure where the clients provide status
From Spring Projects Issue Tracker Beans: public class JavaBean { private NestedBean nested; }
In my company we are 50+ developers. There are around 9 projects that share
I have a C# Solution that includes several websites. Those websites have some communal
I am becoming more and more addicted to the Project Euler problems. However since
I have a lot of classes for data-access in one of my projects, but

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.