VT's Tech Blog » Ajax http://blogs.vinuthomas.com My Tech Discovery Blog on PHP, Ajax, Security and Web 2.0 Tue, 24 Aug 2010 15:59:19 +0000 en hourly 1 http://wordpress.org/?v=3.0.1 Google: Ajax Libraries APIhttp://blogs.vinuthomas.com/2008/05/28/google-ajax-libraries-api/ http://blogs.vinuthomas.com/2008/05/28/google-ajax-libraries-api/#comments Wed, 28 May 2008 15:07:15 +0000 vinu http://blogs.vinuthomas.com/?p=512 Here’s some cool stuff – Google’s Hosting some popular Javascript Ajax libraries like jQuery, prototype and the likes on their servers. You use this service to serve the supported libraries straight off Google. They also provide you with the option to load a particular version of the library so you won’t have to keep checking your code everytime a latest release is made.

Here’s how you would load jQuery version 1.2.3 using this API:

<script src="http://www.google.com/jsapi"></script>
<script>
  // Load jQuery 
  google.load("jquery", "1.2.3");
 //Continue using jQuery
</script>

The AJAX Libraries API is a content distribution network and loading architecture for the most popular open source JavaScript libraries. By using the Google AJAX API Loader’s google.load() method, your application has high speed, globaly available access to a growing list of the most popular JavaScript open source libraries including:

Google works directly with the key stake holders for each library effort and accept the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.

Links:

Google Ajax Libraries

Documentation

Zemanta Pixie
]]>
http://blogs.vinuthomas.com/2008/05/28/google-ajax-libraries-api/feed/ 1
PersistJS: Cross Browser Client-Side Persistent Storagehttp://blogs.vinuthomas.com/2008/05/27/persistjs-cross-browser-client-side-persistent-storage/ http://blogs.vinuthomas.com/2008/05/27/persistjs-cross-browser-client-side-persistent-storage/#comments Tue, 27 May 2008 03:30:50 +0000 vinu http://blogs.vinuthomas.com/?p=509 The Firefox Cookie Manager, showing the details of various cookies by domain

PersistJS is a simple to use Javascript to store persistent data on the client Browser. This library supports multiple back-ends which are listed later. The following example will show you how easy it is to store and retrieve data using PersistJS.

To Store Data:

// create a new client-side persistent data store
var store = new Persist.Store('My Data Store');

// pretend data
var data = "pretend this is really long data that won't fit in a cookie";

// save data in store
store.set('saved_data', data);

To Retreive Data:

// get data back from store, and prompt user with it
store.get('saved_data', function(ok, val) {
  if (ok)
    alert('saved data = ' + val);
});

PersistJS addresses all of the issues above. It currently supports persistent client-side storage through the following backends:

* flash: Flash 8 persistent storage.
* gears: Google Gears-based persistent storage.
* localstorage: HTML5 draft storage.
* whatwg_db: HTML5 draft database storage.
* globalstorage: HTML5 draft storage (old spec).
* ie: Internet Explorer userdata behaviors.
* cookie: Cookie-based persistent storage.

You can also remove storage engines you don’t want to use in PersistJS by removing that storage engine by code:

// never use cookies for persistent storage
Persist.remove('cookie');

Links:
PersistJS Project Home Page
Download PersistJS

]]>
http://blogs.vinuthomas.com/2008/05/27/persistjs-cross-browser-client-side-persistent-storage/feed/ 0
ImageFlow – Javascript Image Galleryhttp://blogs.vinuthomas.com/2008/01/06/imageflow-javascript-image-gallery/ http://blogs.vinuthomas.com/2008/01/06/imageflow-javascript-image-gallery/#comments Sun, 06 Jan 2008 04:19:26 +0000 vinu http://blogs.vinuthomas.com/2008/01/06/imageflow-javascript-image-gallery/ Here’s a cool image gallery script written in Javascript. It’s quite easy to integrate into your site. This is how the author describes ImageFlow:

ImageFlow is a picture gallery, which allows an intuitive image handling. The basic idea is to digitally animate the thumbing through a physical image stack. That intuitive handling is automatically caused by the metaphorical use of the well known process of thumbing through.

The script is compatible with the browsers on Windows, OSX and Linux:

  • IE 6.0+
  • Firefox 2.0.0.9+
  • Opera 6.0+
  • Safari 1.3.2+
  • Konqueror  3.5.7

ImageFlow

The current version of ImageFlow’s features are listed below :

  • Supports most image formats
  • Supports large amounts of images (>100)
  • 100% JavaScript
  • Scroll bar
  • Mouse wheel support
  • Arrow-key support
  • Loading bar
  • Captions
  • Supports image links
  • Scales 100% dynamically
  • Implemented using div Tags

Links:
Download ImageFlow 0.8
ImageFlow Site
ImageFlow Documentation

]]>
http://blogs.vinuthomas.com/2008/01/06/imageflow-javascript-image-gallery/feed/ 4
Record mouse movement using AJAXhttp://blogs.vinuthomas.com/2007/10/22/record-mouse-movement-using-ajax/ http://blogs.vinuthomas.com/2007/10/22/record-mouse-movement-using-ajax/#comments Mon, 22 Oct 2007 14:14:40 +0000 vinu http://blogs.vinuthomas.com/2007/10/22/record-mouse-movement-using-ajax/ Instead of eyeball tracking for usability professionals, here’s a way to track the mouse movements and click events of a user on a page.

The “movelogger� records the mouse movement a users does on a web site. Just before the user leaves the current page, the recorded data get posted back to the server using AJAX.
The cool thing is that you can “replay� these movements afterwards.

Want to try out a demo ? Check this link: http://pure.rednoize.com/movelogger/
Link: puRe aka Marcel Oelke » Record mouse movement using Javascript and AJAX

]]>
http://blogs.vinuthomas.com/2007/10/22/record-mouse-movement-using-ajax/feed/ 1
Really Simple History – History for Ajaxhttp://blogs.vinuthomas.com/2007/09/18/really-simple-history-history-for-ajax/ http://blogs.vinuthomas.com/2007/09/18/really-simple-history-history-for-ajax/#comments Tue, 18 Sep 2007 12:10:49 +0000 vinu http://blogs.vinuthomas.com/2007/09/18/really-simple-history-history-for-ajax/ If you’re working on Ajax based websites, you’ll always face usability problems when users click on the Back or Forward buttons on the broswer. Using Really Simple History (RSH) allows you over come this issue.

The Really Simple History (RSH) framework makes it easy for AJAX applications to incorporate bookmarking and back and button support. By default, AJAX systems are not bookmarkable, nor can they recover from the user pressing the browser’s back and forward buttons. The RSH library makes it possible to handle both cases.

In addition, RSH provides a framework to cache transient session information that persists after a user leaves the web page. This cache is used by the RSH framework to help with history issues, but can also be used by your own applications to improve application performance. The cache is linked to a single instance of the web page, and will disappear when the user closes their browser or clear their browser’s cache.

RSH works on Internet Explorer 6+ and Gecko-based browsers, like Firefox. Safari is not supported.

Link: Really Simple History
Demo Link: testDhtmlHistory.html (try using the browser back button after you get to this demo)

]]>
http://blogs.vinuthomas.com/2007/09/18/really-simple-history-history-for-ajax/feed/ 0
Caching WordPress offline using Google Gearshttp://blogs.vinuthomas.com/2007/06/05/caching-wordpress-offline-using-google-gears/ http://blogs.vinuthomas.com/2007/06/05/caching-wordpress-offline-using-google-gears/#comments Tue, 05 Jun 2007 03:43:38 +0000 vinu http://blogs.vinuthomas.com/2007/06/05/caching-wordpress-offline-using-google-gears/ Google Gears

If you’re still wondering what you can do with Google gears, here are a tutorials to get you started on the right track. Nick Halstead takes you though how to cache WordPress pages using Google Gears:

I was instantly fascinated by Google Gears so I had to immediately try out the sample code that you can download. The tutorial on the website gives a simple example of how to cache a few files using the Resource Store. It makes it very easy to setup a JSON manifest file that contains which pages you want to have cached.

Link: Google Gears Caching of WordPress in PHP

]]>
http://blogs.vinuthomas.com/2007/06/05/caching-wordpress-offline-using-google-gears/feed/ 0
Google Gears for offline appshttp://blogs.vinuthomas.com/2007/05/31/google-gears-for-offline-apps/ http://blogs.vinuthomas.com/2007/05/31/google-gears-for-offline-apps/#comments Thu, 31 May 2007 06:51:46 +0000 vinu http://blogs.vinuthomas.com/2007/05/31/google-gears-for-offline-apps/ Google has released a beta version of Google Gears which is an open source browser extension which  enables web applications to provide offline functionality using following JavaScript APIs.

Here’s what you can do with the API’s:

  • Store and serve application resources locally
  • Store data locally in a fully-searchable relational database
  • Run asynchronous Javascript to improve application responsiveness

You can take a look at the sample applications at http://code.google.com/apis/gears/sample.html once you install the browser plugin.

The news out there is that Google’s planning to offer offline support for their current applications like Google Reader, Docs & Spreadsheets.

]]>
http://blogs.vinuthomas.com/2007/05/31/google-gears-for-offline-apps/feed/ 0
PHPLiveX – Tutorialhttp://blogs.vinuthomas.com/2007/05/18/phplivex-tutorial/ http://blogs.vinuthomas.com/2007/05/18/phplivex-tutorial/#comments Fri, 18 May 2007 07:26:49 +0000 vinu http://blogs.vinuthomas.com/2007/05/18/phplivex-tutorial/ If you’re looking for the quickest way to get your PHP functionality Ajax enabled, you’ve got to take a look at PHPLiveX. It greatly simplifies the process of Ajaxifying your PHP code without knowing Javascript code.

Let’s see how to Ajaxify a simple PHP function. Let’s create a simple function to output the server time:

function myServerTime(){
	return date("D M j G:i:s T Y");
}

First you have to include the PHPLiveX library and register your function. Here’s how to to it:

<? php
  include 'PHPLiveX.php';
 
	function myServerTime(){
		return date("D M j G:i:s T Y");
	}
 
  $phplive = new PHPLiveX("myServerTime"); //Register the function with PHPLiveX
?>

$phplive = new PHPLiveX(“myServerTime”); is used to register our function myServerTime with PHPLiveX

Next let’s build our HTML Display. Let’s keep it simple, but allowing the user to click a link to get the updated server time:

 <a href="">Get Server Time </a>

Now we’ll have to create areas to display our Loading Status and the results back from the server. Let’s create two divs for this.

<span id="loading" style="visibility:hidden">Loading...</span>
<span id="serverResult" style='clear:both;'></span>

You’ll notice that the loading span’s visibility has been set to hidden by default. PHPLiveX will use this to show the loading indicator when an action is being performed.

Now let’s get the entire HTML created. PHPLiveX autogenerates the Javascript required to create the AJAX calls, this has to take place in the html head section. To generate the Javascript all you need to call is $phplive->Run(). So let’s get to the entire script with the HTML:

<? php
  include 'PHPLiveX.php';
 
	function myServerTime(){
		return date("D M j G:i:s T Y");
	}
 
  $phplive = new PHPLiveX("myServerTime"); //Register the function with PHPLiveX
?>
<html>
	<head>
		<title>My Ajax Server Time</title>
		<script>
			<?php
				$phplive->Run();
			?>
		</script>
</head>
<body>
 
<a href="javascript:myServerTime('', 'target=serverResult,preload=loading');">Get Server Time</a>
 
<span id="loading" style="visibility:hidden">Loading...</span>
<span id="serverResult"></span>
</body>
</html>

You’ll notice that in the Get Server Time link there’s a little bit of Javascript – javascript:myServerTime(”, ‘target=serverResult,preload=loading’);. That’s used to call the myServerTime function from Javascript. The first parameter is null since our function myServerTime doesn’t accept any parameters. The second parameter tells PHPLiveX to send the output to the “serverResult” div and use the “loading” div as the preloader.

That’s it ! You can see a demo of this here.
Get the source code for this tutorial here. This includes version 2.2 of the PHPLiveX library.

I’ll put up a tutorial on how to use PHPLiveX for a whois lookup next week.

Link to PHPLiveX: PHPLiveX -> An Open Source PHP/Ajax Library

]]>
http://blogs.vinuthomas.com/2007/05/18/phplivex-tutorial/feed/ 9
miniajax.comhttp://blogs.vinuthomas.com/2007/03/05/miniajaxcom/ http://blogs.vinuthomas.com/2007/03/05/miniajaxcom/#comments Mon, 05 Mar 2007 03:27:45 +0000 vinu http://blogs.vinuthomas.com/2007/03/05/miniajaxcom/ miniajax.com

Miniajax.com is a showcase ofwhat’s hot in Ajax, with link to demos and tutorials showing how they’re done. Here are some of what you can see at miniajax.com

  • Ajax StarRating
  • Ajax Contact Form
  • In-place editing (like Flickr)
  • Bubble Tool-tips
  • Heatmap for websites and much more…

Link: miniajax.com

]]>
http://blogs.vinuthomas.com/2007/03/05/miniajaxcom/feed/ 1
SQL Designerhttp://blogs.vinuthomas.com/2006/08/28/sql-designer/ http://blogs.vinuthomas.com/2006/08/28/sql-designer/#comments Mon, 28 Aug 2006 09:22:25 +0000 vinu http://blogs.vinuthomas.com/2006/08/28/sql-designer/

Looking for a quick way to design Databases without having to download software? Here’s an Ajax application which allows you to design databases online without having anything other than a web browsers installed on your system :)

This application allows you to define your tables and rows through an easy to use web interface. You can also link tables together by dragging and dropping the primary keys into other tables. You can export the database tables as XML, MS SQL and SQL Server statements.

Link: SQL Designer

]]>
http://blogs.vinuthomas.com/2006/08/28/sql-designer/feed/ 1
AJAX ActiveTablehttp://blogs.vinuthomas.com/2006/08/08/ajax-activetable/ http://blogs.vinuthomas.com/2006/08/08/ajax-activetable/#comments Tue, 08 Aug 2006 13:32:45 +0000 vinu http://blogs.vinuthomas.com/2006/08/08/ajax-activetable/ Here’s a cool use for Ajax – an active table were users can edit and add columns into a table in HTML.

The ActiveTable library creates an editable HTML table from a MySQL database table.

Link: AJAX ActiveTable – Jonathan Diehl’s Wiki

Here’s a Demo of Ajax Active Table (This loads from the author’s site in an iframe and may take some time to load):

]]>
http://blogs.vinuthomas.com/2006/08/08/ajax-activetable/feed/ 3
Handling large files with(out) PHPhttp://blogs.vinuthomas.com/2006/08/04/handling-large-files-without-php-thinkphp-devblog/ http://blogs.vinuthomas.com/2006/08/04/handling-large-files-without-php-thinkphp-devblog/#comments Fri, 04 Aug 2006 08:34:19 +0000 vinu http://blogs.vinuthomas.com/2006/08/04/handling-large-files-without-php-thinkphp-devblog/ As one man was quoted “640K of memory should be enough for anybody” no one will need to access more than 2 GB data. What happens if you – just for scientific reasons of course – try to access larger files using your 32bit hardware and your favorite programming language PHP?

Read on: Handling large files with(out) PHP – ThinkPHP /dev/blog

]]>
http://blogs.vinuthomas.com/2006/08/04/handling-large-files-without-php-thinkphp-devblog/feed/ 0
Creating an Ajax feedback form with My-Bichttp://blogs.vinuthomas.com/2006/07/11/creating-an-ajax-feedback-form-with-my-bic/ http://blogs.vinuthomas.com/2006/07/11/creating-an-ajax-feedback-form-with-my-bic/#comments Tue, 11 Jul 2006 09:36:48 +0000 vinu http://blogs.vinuthomas.com/2006/07/11/creating-an-ajax-feedback-form-with-my-bic/ My-Bic is an Ajax framework for PHP. It allows you to easily integrate Ajax features into your PHP applications. Let’s see how to create a feedback form with My-Bic.

Installation and Setup:

Download the latest version of My-Bic (v0.6.3) from http://www.litfuel.net/mybic/index.html?page=download and copy the files over a folder under the webroot of your server.

You’ll need to change the following lines in the mybic_server.php file :

define("SERVER_ROOT", "d:/wamp/www/mybic/");
This defines the base path of the folder where this file exists.

define("INC_PATH", SERVER_ROOT);
This defines where your custom classes will be places. Let’s leave this as it is for this tutorial.

Client-Side
Let’s start with a basic form which you’ll need for feedback:


Feedback Form

Name :
Email:
Feedback:



In this form we’ll have to create an action when the user clicks on the submit button, so let’s change the last line of code to:

Let’s check out the JavaScript required to power this Ajaxified Feedback form.
In the HEAD section of the HTML, we’ll have to include the “mybic.js” file required to power this application. We’ll also have to create the sendComment() function which will be called when the user clicks on the submit button. Let’s take a look at the following code:



We have the required JavaScript file included using the line:

We’re instantiating a new Ajax Object using:
var ajaxObj = new XMLHTTP("mybic_server.php");

We’re setting up debugging by using ajaxObj.debug = 1; this gives a window which shows us what requests are posted and the results from the server.

function sendComment()
{
ajaxObj.format = "TEXT";
var form_vars = ajaxObj.getForm('feedback');
ajaxObj.call('action=ajaxfeedback'+form_vars, showResults);
}

In the code above, we’re setting up the function to actually execute the Ajax call. The first line in the function specifies that we’re expecting the return results in Text instead of JSON.

var form_vars = ajaxObj.getForm('comments'); will loop through the form to get all the fields and values.

ajaxObj.call('action=ajaxfeedback'+form_vars, showResults); Calls the class ajaxfeedback on the server with the form values and will call the showResults function to output the server response back to screen.

function showResults(resp)
{
document.getElementById('message').innerHTML = resp;
}

The showResults function replaces the contents of the message div with the response back from the server.

Let’s save this file as ajaxfeedback.html

Here’s the entire code for this file:





Feedback Form

Name :
Email:
Feedback:


Server Side
On the client side, we’re calling a class ajaxfeedback to process the request. Let’s get to creating the server-side program to process the request. The file you’ll have to create will be ajaxfeedback.php. In this file let’s put in the following code:

class ajaxfeedback {
var $queryVars;
function ajaxfeedback( $queryVars )
{
$this->queryVars = $queryVars;
}
/**
* Method to return the status of the AJAX transaction
*
* @return string A string of raw HTML fetched from the Server
*/
function return_response()
{
$resp = 'ok';
return $resp;
}
function is_authorized()
{
return true;
}
}

?>

Looking at the code, you’ll see that we’re creating a class called ajaxfeedback which has a constructor which takes the query variables and sets it internally.
The return_response method is used to return the status of the Ajax transaction. In this method let’s add a little bit of form validation:

function return_response()
{
// Save Inputs to database here and create the return
// result
if ( $this->queryVars['name'] == "" ) {
$resp = "Please enter your name";
} else
if ( $this->queryVars['email'] == "" ) {
$resp = "Please enter your email id";
} else
if ( $this->queryVars['feedback'] == "" ) {
$resp = "Please enter your feedback";
} else {
// Save Inputs to database here
$resp = "Thank you for your comments";
}
return $resp;
}

In the last else statement, you can insert your database routine to save the form values. Once saved we’re passing on a confirmation message back to the client-side.

Now your completed ajaxfeedback.php should look like :

class ajaxfeedback {
var $queryVars;
function ajaxfeedback( $queryVars )
{
$this->queryVars = $queryVars;
}
/**
* *
* Method to return the status of the AJAX transaction
*
*
* @return string A string of raw HTML fetched from the Server
*/
function return_response()
{
// Save Inputs to database here and create the return
// result
if ( $this->queryVars['name'] == "" ) {
$resp = "Please enter your name";
} else
if ( $this->queryVars['email'] == "" ) {
$resp = "Please enter your email id";
} else
if ( $this->queryVars['feedback'] == "" ) {
$resp = "Please enter your feedback";
} else {
// Save Inputs to database here
$resp = "Thank you for your comments";
}
return $resp;
}
function is_authorized()
{
return true;
}
}

?>

Your Ajax feedback form is ready to use. Fire up your browser and open ajaxfeedback.html in your browser. If you’d like to see a demo of this form, head over to :

http://vinuthomas.com/code/my-bic/ajax_feedback.html

You’ll see the debug window open up as soon as you submit the form. The debug window gives you information useful while debugging you ajax application.

Source code for this tutorial: ajax_feedback.zip

]]>
http://blogs.vinuthomas.com/2006/07/11/creating-an-ajax-feedback-form-with-my-bic/feed/ 2
Design Patterns for Web 2.0http://blogs.vinuthomas.com/2006/06/29/design-patterns-for-web-20/ http://blogs.vinuthomas.com/2006/06/29/design-patterns-for-web-20/#comments Thu, 29 Jun 2006 05:55:24 +0000 vinu http://blogs.vinuthomas.com/2006/06/29/design-patterns-for-web-20/ Yahoo’s UI Blog and Design pattern Library have interesting topics on patterns to follow while designing UI’s for Web 2.0 applications. In the old web, an action almost always followed a page reload or an intrusive Javascript pop-up, indicating that the action was complete. In the age of Ajax, how do we communicate the action completion to the user?Transitions are a powerful way to communicate change in a user interface. Transitions can communicate a change in relationships between elements on a page or a change in an element’s state. Additionally, when interactions are complex or involve important changes transitions can be used to slow down an interaction allowing the user to “see what just happened.” During lengthy processes, transitions can be used to make time seem to pass faster by distracting the user during the waiting time. 

Transition Parent – Yahoo! Design Pattern Library

With the widespread acceptance of Ajax (and the resurgence of Flash) new ways of interacting on the web have emerged. In many ways, these interactions are not new. Interactions like drag and drop and inline editing have been mainstream on desktop applications for over 20 years. What is new, though, is the emergence of these idioms on the web. 

Link: Design Pattern: Invitation

Another interesting link on this topic: Mind Hacking Visual Transitions

]]>
http://blogs.vinuthomas.com/2006/06/29/design-patterns-for-web-20/feed/ 1
Snap – Ajax powered Searchhttp://blogs.vinuthomas.com/2006/06/15/snap-ajax-powered-search/ http://blogs.vinuthomas.com/2006/06/15/snap-ajax-powered-search/#comments Thu, 15 Jun 2006 03:36:30 +0000 vinu http://blogs.vinuthomas.com/2006/06/15/snap-ajax-powered-search/ Snap Search EngineHere’s a cool new search engine powered by Ajax. They’ve got Ajax powered “suggest” features while you type, you can scroll through your results using the arrow keys on your keyboard, view result pages inline and lots more…. check out Snap.

Snap is a very different way of searching, one we suspect will take a bit of getting used to. As you can imagine, we’ve done a ton of usability testing in developing Snap and here’s what we’ve learned: while Snap isn’t complicated, it is a different way of searching in which a little bit of orientation goes a long way to increasing satisfaction. So, we’ve tried to help introduce ourselves to you in a number of ways.

Link: Snap

]]>
http://blogs.vinuthomas.com/2006/06/15/snap-ajax-powered-search/feed/ 0
http://blogs.vinuthomas.com/2006/06/08/comet-it%e2%80%99s-ajax-for-%e2%80%9cpush%e2%80%9d/ http://blogs.vinuthomas.com/2006/06/08/comet-it%e2%80%99s-ajax-for-%e2%80%9cpush%e2%80%9d/#comments Thu, 08 Jun 2006 13:50:56 +0000 vinu http://blogs.vinuthomas.com/2006/06/08/comet-it%e2%80%99s-ajax-for-%e2%80%9cpush%e2%80%9d/ Alex Russell has coined a term for a flavour of Ajax that’s been getting more attention of late. Comet describes applications where the server keeps pushing – or streaming – data to the client, instead of having the browser keep polling the server for fresh content.

Link: Software As She’s Developed – Comet: It’s Ajax for “Pushâ€? (Podcast)

]]>
http://blogs.vinuthomas.com/2006/06/08/comet-it%e2%80%99s-ajax-for-%e2%80%9cpush%e2%80%9d/feed/ 0