Home arrow PHP arrow PHP and JavaScript Interaction: Storing Data in the Client, part 1

PHP and JavaScript Interaction: Storing Data in the Client, part 1

Modern websites demand heavy interaction between server-side and client-side programming. In the first part of this article series, we will implement a simple mechanism to make PHP and JavaScript interact, creating a function which can build an array structure and store information in it. It will allow for programmatic data manipulation without server interaction.

  1. PHP and JavaScript Interaction: Storing Data in the Client, part 1
  2. Lord of the Arrays
  3. Building JavaScript Arrays with PHP: the "createJavascript()" function
  4. Dealing with result sets
  5. Getting practical: putting the "createJavaScript()" function into action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 55
May 04, 2005

print this article




Certainly the concepts have been covered repeatedly in countless articles, books or papers you can imagine, digging into the territory of Web development: server-side and client-side programming. While nowadays these areas are clearly differentiated and stand on their own in distinct scenarios, the requirements of modern websites demand heavy interaction between them. From database-generated navigational menus, to server-based CSS style manipulation, examples of server-client programming interaction are truly vast and numerous.

In most situations, this interaction is bi-directional. You might see either server-side languages, such as PHP, generating client-code, that means JavaScript/(X)HTML, or JavaScript functions building up data to be processed in the server. Either way, the process is often a two-way street. Particularly, if we take into consideration the first half of the equation, where PHP (or the server-side language of your choice) performs some kind of quick client-program generation, we rapidly end up storing some temporary data directly in the client computer's memory.

Of course, here we're discarding any other well-known client-side storage process, such as cookies, image-based data tracking, data coming in from local cached files or even from XML files. This issue immediately brings to mind a question that has caused several heated discussions: is it good to store data in the client this way? The range of opinions varies widely from a rough complaint to a resounding yes. The truth is that the answer is hard to give, since it relies strongly on several factors, such as amount of data, type, user hardware (remember we're using client system resources) and particularly data relevance.

Definitely, we'll agree that no critical data will be stored in the client, even if this sounds like common sense stuff. If you ever thought that critical information should be stored in the user's environment, please change your mind right now! However, regarding my personal experience, when building applications that heavily eat up a client's computer resources, difficulties can easily appear, causing browser crashes or complete system hangs.

But, all is not lost. As hardware rapidly evolves, and it's widely available to average users, there are certain cases where it is possible and even desirable to have a small application directly using the client's memory to store temporary data.

That's where this article series comes in. We'll demonstrate how to use this approach to store data in the client and noticeably reduce the client-server transferring process, developing a couple of applications useful for implementation on any project of your choice. Let's get ready to try out a combination of PHP and JavaScript.

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: