- HubPages»
- Technology»
- Computers & Software»
- Computer Science & Programming»
- Programming Languages
Server side coding options - AJAX and the graphing calculator - Part 4 in a series
Javascript on the server
The What and Why of Server Side Scripting
In the previous hubs in this series, I introduced how to retrieve data from a Web server using AJAX, and a simple application for charting personal geographies. In order to take this application further, I will need to start developing code on the server side. Basically, fetching already prepared data files from a server, is not very flexible and limits how feature rich the application can be. Using code running on the server to prepare custom data in response to a request opens up many more possibilities.
Let's call the application that I want to develop Geo-match, users will log their daily travels into the application. In return for this effort, they will be able to chart how their daily routes compare with geo-friends and maybe find some new people to meet or new places to go.
First, we need to pick the the programming language(s) we want to use on the server side. The basic requirement is that the language is integrated into a Web server in such a way that an HTTP request can cause code in that language to execute and produce output that is the response to the HTTP request. That is not a very restrictive requirement. So, there are a lot of possibilities. We could even use Javascript on the server side. More common choices would be to use Ruby, Python, Java, Perl, PHP, or if you are a Microsoft affectionado, C#. One can have many technical debates about the merits, or lack thereof, for all these choices, but in the end, they are all capable of doing what is required to implement Geo-match. So, I will pick PHP, because it is convenient for me.
I will also pick one other mechanism that will be helpful in developing Geo-match; a database. There are many options here, as well. I could construct my own database out of plain files. I could use some No-SQL option, such as, Cassandra. Or, I could use a traditional, relational database. I will pick MySQL, because it is a common choice, it will meet the immediate needs of Geo-match, I don't have to pay anything to use it, and it is convenient for me.
There are lots of tutorial materials on both PHP and MySQL that are available on the Web. I won't endevour to replicate those in this series. Rather, I will just cover enough to carry on with the development of my Javascript application. If you want to follow along in this series of Hubs, you might want to install these two technologies on your system. They are both easily available on either Windows, or Linux.
In order to implement Geo-match, I will have users enter route entries that contain places they visited: who? where? when?
My server side code will translate requests for user routes based on a user name and a period of time. The output will be the XML format for describing a person's route that I introduced in a previous Hub. This output will be charted by the same Javascript based graphing calculator application that I have used to illustrate my programming points through out this series of Hubs.
Potentially, I would need to develop a lot of infrastructure before Geo-match could go live. I would need ways for users to setup accounts, and login, convenient ways to enter location data, etc. However, I am going to ignore all that. My objective is to illustrate how server side programming can be used to enhance a Javascript application.
In my next Hub on this topic, I will start laying code. In this Hub, I just wanted to motivate why server side code is useful and cover some of the choices of technology that is available to use.