Blog of Tejas Shirodkar

AJAX and PHP Rock!!!

by on Jun.02, 2009, under Development

Ladies and gentlemen!!! Yours truly just ajax’d the shit out of the main web site XD

I chanced to look upon the contact page which previously used redirects and it seemed a very lame way to do it. What better way to improve it than use Ajax. That was just the beginning.

After having fixed the contact page, I had this urge to ‘fix’ some more of the site. There are hardly a couple of pages on the main site and it seems to be a waste of time to wait for all the images and rest of the stuff to load, while waiting for a little extra content.  I immediately wanted to make the site completely AJAX based. The only issue now seemed to be the people who for some reason disabled java script.

I googled a bit and most of the solutions to check whether the user had disabled javascript and do things differently seemed an extra overhead than the speed up ajax offered. Now personally it makes no sense to me to make the load times vary greatly for users with different settings.

The persistent me only took a couple of minutes to figure out the most ideal solution. In all these years one thing which I have learned and come to agree on is that –

“Most implementation based programming problems, almost always have simple solutions. One just needs to look hard enough for them.”

Here it is my friends, the simple solution – onClick() functions that cancel the redirect. The only requirement here is that the content needs to be modular. Which fortunately with my programming style it always is. In case javascript is not present the browser is redirected and the page is generated with the complete layout. When it is the way it should be, the ajax function is called which retrieves the content and our page is updated. Simple and effective.

Sometimes little things in life make you feel really proud and happy, maybe it’s the joys of being a programmer or maybe it’s just me 🙂

P.S. I fixed my download stats tool as well. It wasn’t poping up the file download for pdf’s in firefox which i noticed after uploading my cv.

:, , ,
No comments for this entry yet...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!