Skip to content
nbigot edited this page Jul 21, 2012 · 5 revisions

Welcome to the postalcodesearch wiki!

postalcodesearch

postalcodesearch is a javascript library/demo for postal codes search or zip search using jquery mobile.

Notes about the jquery mobile code modification

This demo is using

  • jquery 1.7.1
  • jquery mobile 1.1.0 (but there is a small modification)

The jquery mobile 1.1.0 modification is:

			.bind( "keyup change", function() {

			/* begin modification */
			if ( typeof(listview.options.onKeyUpCallback) !== "undefined" ) {
				listview.options.onKeyUpCallback( $(this), list );
			}
			/* end modification */

			var $this = $(this),
				val = this.value.toLowerCase(),
				listItems = null,
				lastval = $this.jqmData( "lastval" ) + "",
				childItems = false,
				itemtext = "",
				item;

Notes about the postal codes database access

The database is just a simple javascript varaible which contains a huge array of postal codes. There is no SQL. You can include a javascript file that contains this variable (for example you can name it zipcodes.js) With this way of doing there is NO asynchronous ajax call to a web service because of those reasons:

  • a simple javascript file is complient with offline browsing webapp
  • it's easier to maintain code / no need to check web service is up
  • it's server friendly (no CPU waste and no webservice to call each time the user press a key)
  • yes it's consuming a lot of bandwidth but you can use cache and manifest to keep it localy for a long time, and you can put the file on a CDN within a cookieless domain