<?xml version="1.0" encoding="utf-8"?>

			<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

			<channel>
			<title>Blog of Shaun McCran - Architecting robust, elegant technical and business solutions - AJAX</title>
			<link>http://www.mccran.co.uk/index.cfm</link>
			<description>I write about Architecture and Design, Architectural patterns, Architectural Principles and Architectural policies. This includes TOGAF, Zachman, Business Architecture, SOA and Process and tools such as the IBM Rational software and Adobe products. I also write about my previous life as a mobile and web developer.</description>
			<language>en-gb</language>
			<pubDate>Tue, 09 Jun 2026 06:56:22 -0000</pubDate>
			<lastBuildDate>Thu, 20 Oct 2011 13:53:00 -0000</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>shaun@mccran.co.uk</managingEditor>
			<webMaster>shaun@mccran.co.uk</webMaster>
			<itunes:subtitle></itunes:subtitle>
			<itunes:summary></itunes:summary>
			<itunes:category text="Technology" />
			<itunes:category text="Technology">
				<itunes:category text="Podcasting" />
			</itunes:category>
			<itunes:category text="Technology">
				<itunes:category text="Tech News" />
			</itunes:category>
			<itunes:keywords></itunes:keywords>
			<itunes:author></itunes:author>
			<itunes:owner>
				<itunes:email>shaun@mccran.co.uk</itunes:email>
				<itunes:name></itunes:name>
			</itunes:owner>
			
			<itunes:explicit>no</itunes:explicit>
			
			
			
			
			
			<item>
				<title>Using URL hashes to control AJAX requests</title>
				<link>http://www.mccran.co.uk/index.cfm/2011/10/20/Using-URL-hashes-to-control-AJAX-requests</link>
				<description>
				
				Following on from my previous article here (&lt;a href=&quot;http://www.mccran.co.uk/index.cfm/2011/10/17/Adding-hash-values-into-URLs--The-basics&quot; target=&quot;_blank&quot;&gt;http://www.mccran.co.uk/index.cfm/2011/10/17/Adding-hash-values-into-URLs--The-basics&lt;/a&gt;) this article deals with injecting Hash values into URL&apos;s and using them to power AJAX requests.

Starting with the code of the previous article I&apos;ll expand it to include an AJAX request based on the Hash inserted into the URL.
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Javascript</category>
				
				<category>AJAX</category>
				
				<pubDate>Thu, 20 Oct 2011 13:53:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2011/10/20/Using-URL-hashes-to-control-AJAX-requests</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Adding hash values into URLs - The basics</title>
				<link>http://www.mccran.co.uk/index.cfm/2011/10/17/Adding-hash-values-into-URLs--The-basics</link>
				<description>
				
				Building a site that uses AJAX to Asynchronously import content into it? You can take advantage of the URL hash value and some of the functionality it gives you. 

By inserting a hash character into the URL you can pick up the string following it and use it as a value in AJAX requests. Also you can create a listener event to check for a hash being added to a URL and use that to activate your custom JavaScript.

This blog entry is an intro to this process, where we deal with adding the hash value into a URL.
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Javascript</category>
				
				<category>AJAX</category>
				
				<pubDate>Mon, 17 Oct 2011 15:26:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2011/10/17/Adding-hash-values-into-URLs--The-basics</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Architectural issues with AJAX requests and user journeys</title>
				<link>http://www.mccran.co.uk/index.cfm/2011/10/13/Architectural-issues-with-AJAX-requests-and-user-journeys</link>
				<description>
				
				The more I use non standard ways of loading data and online content the more issues I uncover with how users can interact with a platform.

Adopting new technologies to build applications is all well and good but what implications does this bring to bear on your users? How do they apply their normal usage habits to your new and differently architected application?
				 [More]
				</description>
				
				
				<category>Best practices</category>
				
				<category>AJAX</category>
				
				<pubDate>Thu, 13 Oct 2011 14:58:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2011/10/13/Architectural-issues-with-AJAX-requests-and-user-journeys</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Combining JQuery Datatable with drag and drop functions</title>
				<link>http://www.mccran.co.uk/index.cfm/2011/5/15/Combining-JQuery-Datatable-with-drag-and-drop-functions</link>
				<description>
				
				&lt;p&gt;
The datatables JQuery plugin ( &lt;a href=&quot;http://www.datatables.net/&quot; target=&quot;_blank&quot;&gt;http://www.datatables.net/&lt;/a&gt; ) is an incredibly powerful way of displaying tabular data and allowing the user to manipulate it without leaving the current view.
&lt;p&gt;
The plugin already features paging and sorting, but what if you want to extend the plugin with some other non default behaviours like drag and drop? Using a previous example ( &lt;a href=&quot;http://www.mccran.co.uk/index.cfm/2010/4/29/JQuery-Datatables-plugin-example-using-a-server-side-data-request-coldfusion&quot; target=&quot;_blank&quot;&gt;http://www.mccran.co.uk/index.cfm/2010/4/29/JQuery-Datatables-plugin-example-using-a-server-side-data-request-coldfusion&lt;/a&gt; ) as a starting point I thought I&apos;d try and integrate drag and drop with the datatable object.
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Javascript</category>
				
				<category>AJAX</category>
				
				<pubDate>Sun, 15 May 2011 01:10:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2011/5/15/Combining-JQuery-Datatable-with-drag-and-drop-functions</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Dynamically adding markers to Google maps</title>
				<link>http://www.mccran.co.uk/index.cfm/2011/1/15/Dynamically-adding-markers-to-Google-maps</link>
				<description>
				
				&lt;p&gt;
Following on from a previous article I wrote about (&lt;a href=&quot;http://www.mccran.co.uk/index.cfm/2011/1/11/Google-maps-panning-example&quot;&gt;Google maps panning&lt;/a&gt; the next step in my Google mapping project is to be able to add markers to a Google map dynamically.
&lt;p&gt;
This article deals with how to translate a location into a latitude and longitude using Google, and how to send and add markers from a database into a Google maps via a remote service, using AJAX and JSON.
&lt;p&gt;
There is a full example of the finished application here: &lt;a href=&quot;http://www.mccran.co.uk/examples/maps/recording.cfm&quot; target=&quot;_blank&quot;&gt;Demo of dynamically adding markers to Google maps&lt;/a&gt;
&lt;p&gt;
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Google</category>
				
				<category>Development</category>
				
				<category>Coldfusion</category>
				
				<category>AJAX</category>
				
				<pubDate>Sat, 15 Jan 2011 19:24:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2011/1/15/Dynamically-adding-markers-to-Google-maps</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Filtering a SELECT field using AJAX and JQuery</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/12/22/Filtering-a-SELECT-field-using-AJAX-and-JQuery</link>
				<description>
				
				I&apos;ve got a select form field, and I want it to change based on a search string that someone enters. Luckily for me the select field is dynamically driven from a database, so the most obvious way for me to do this is to make an AJAX post request using the string entered to amend the SQL query building the field.
&lt;p&gt;
This article shows you how to do this, there is a demo of the select field using AJAX here: &lt;a href=&quot;http://www.mccran.co.uk/examples/jquery_textfilter_selectfield/&quot; target=&quot;_blank&quot;&gt;http://www.mccran.co.uk/examples/jquery_textfilter_selectfield/&lt;/a&gt;
&lt;p&gt;
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>RIA</category>
				
				<category>AJAX</category>
				
				<pubDate>Wed, 22 Dec 2010 09:51:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/12/22/Filtering-a-SELECT-field-using-AJAX-and-JQuery</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>JQuery AJAX Http polling example</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/9/26/JQuery-AJAX-Http-polling-example</link>
				<description>
				
				I&apos;ve been using the JQuery post() and get() functions for a while now, and thanks to decent Blog entries from other community members I&apos;ve got my head around the principles of seamless AJAX http requests and response handling.
&lt;p&gt;
This article examines a way of creating a polling AJAX http request. This is a request that will run every &lt;i&gt;N&lt;/i&gt; seconds based on a value. It will hit a remote service and return a result, and display that result on screen.
&lt;p&gt;
View a full demo of an &lt;a href=&quot;http://www.mccran.co.uk/examples/jquery-polling/index.cfm&quot; target=&quot;_blank&quot;&gt;AJAX polling request here.&lt;/a&gt;
&lt;p&gt;
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>Json</category>
				
				<category>AJAX</category>
				
				<pubDate>Sun, 26 Sep 2010 19:05:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/9/26/JQuery-AJAX-Http-polling-example</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Cross site AJAX HttpRequest problems and how to create a Proxy handler</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/7/19/Cross-site-AJAX-HttpRequest-problems-and-how-to-create-a-Proxy-handler</link>
				<description>
				
				Most of us are familiar with the AJAX post() and getJSON() methods of remotely calling and passing around data, I use them with abundance when building applications. One thing I had not considered until recently is that all my AJAX Http requests are usually internal to that application, which also means they are on the same server and domain.

I recently jumped into a project where the application spanned 24 domains, and had been developed to use a core component library to help code re use. The problem with this arose when you are on one domain (www.domain1.com) and you want to make a request to a different domain (www.domain2.com). You encounter something called the &apos;same-Origin&apos; policy.

This article deals with how to create a proxy to handle cross site AJAX http Requests.
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>Json</category>
				
				<category>AJAX</category>
				
				<pubDate>Mon, 19 Jul 2010 15:36:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/7/19/Cross-site-AJAX-HttpRequest-problems-and-how-to-create-a-Proxy-handler</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>How to reload a JQuery Datatables table data, using the API</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/7/2/How-to-reload-a-JQuery-Datatables-table-data-using-the-API</link>
				<description>
				
				Since I found the JQuery dataTables plugin, I use it quite a lot. I think it&apos;s a great way to display tabulated data, and it provides simple easy to use pagination and filtering options.

I&apos;ve been building an interface to manage data, and arrived at the need to reload a datatable powered table, through a JavaScript request, rather than a page reload, or external variable (Url or form).

The problem with this is that if you try and re initialise a datatable into an existing datatable you get an error:

&lt;code&gt;
DataTables warning: Unable to re-initialise DataTable. Please use the API to make any configuration changes required.
&lt;/code&gt;

So you cannot re initialise an existing dataTable object. Looking through the &lt;a href=&quot;http://datatables.net/api&quot; target=&quot;_blank&quot;&gt; API methods&lt;/a&gt; there is a relatively straight forward fix.

&lt;code&gt;
if (typeof dTable == &apos;undefined&apos;) {

	dTable = $(&apos;#example&apos;).dataTable( {
	// data tables code
	&quot;bProcessing&quot;: true,
	&quot;bStateSave&quot;: true,
	&quot;bServerSide&quot;: true,
etc...
	aoData.push({ &quot;name&quot;: &quot;pageFilter&quot;, &quot;value&quot;: filterText });
	});
else
		{
			dTable.fnDraw();
		}
&lt;/code&gt;

This code is basically checking if the object &apos;dTable&apos; already exists, and if it is we are re drawing it, rather than using the existing object.

The fnDraw() method re-draws the table, so the data is refreshed. It uses the fnClearTable() method to first clear an existing data set, and the re draws it.

As an aside the &apos;filterText&apos; value is a JavaScript value set elsewhere (a select field) that I am sending through to my server side request. It is used in a simple where clause in a query.
				
				</description>
				
				
				<category>JQuery</category>
				
				<category>RIA</category>
				
				<category>AJAX</category>
				
				<pubDate>Fri, 02 Jul 2010 18:38:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/7/2/How-to-reload-a-JQuery-Datatables-table-data-using-the-API</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>JQuery Datatables plugin example using a server side data request (coldfusion)</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/4/29/JQuery-Datatables-plugin-example-using-a-server-side-data-request-coldfusion</link>
				<description>
				
				Im my previous article on how to use the JQuery datatables plug I concentrated mainly on the JQuery script, and how to build the AJAX request to receive a JSON response. 

In this article I will demonstrate the full application which will include the front end JQuery, building the back end server response and a few tips that I&apos;ve picked up since implementing the plugin. I am using an MS SQL table filled with UK location data that I also used for a weather webservice, to fill the table.

A full example of this working can be seen here: &lt;a href=http://www.mccran.co.uk/examples/datatable/index.cfm target=_blank&gt;Data table server side example&lt;/a&gt;
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>Javascript</category>
				
				<category>RIA</category>
				
				<category>Json</category>
				
				<category>AJAX</category>
				
				<pubDate>Thu, 29 Apr 2010 18:04:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/4/29/JQuery-Datatables-plugin-example-using-a-server-side-data-request-coldfusion</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>What does &quot;Invalid Label&quot; mean in a JSON response, and how can I fix it?</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/3/23/What-does-Invalid-Label-mean-in-a-JSON-response-and-how-can-I-fix-it</link>
				<description>
				
				I recently build an application that returned a JSON object of data based on a select field value. Whilst I was building this I encountered an error using the JavaScript eval() function on my JSON response. I am using the eval() function to parse a string from my JSON response, but firebug is showing a JavaScript error of &quot;Invalid Label&quot;.

This is the code:

&lt;code&gt;

function(data){
	jsonResponse = eval(data);
	var src = jsonResponse.DATA;
	});
&lt;/code&gt;

After having a Google around it appears that the eval function is interpreting the first item in the JSON response as a label, rather than data. By changing the code like this:

&lt;code&gt;
jsonResponse = eval(&quot;(&quot; + data + &quot;)&quot;);
&lt;/code&gt;

We are forcing eval to recognise the data as variable data. Now the JSON to string translation works.
				
				</description>
				
				
				<category>JQuery</category>
				
				<category>Javascript</category>
				
				<category>Json</category>
				
				<category>AJAX</category>
				
				<pubDate>Tue, 23 Mar 2010 14:36:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/3/23/What-does-Invalid-Label-mean-in-a-JSON-response-and-how-can-I-fix-it</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Using other plug-ins with the JQuery Carousel Plug-in and event issues</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/3/15/Using-other-plugins-with-the-JQuery-Carousel-Plugin-and-event-issues</link>
				<description>
				
				This entry examines how the JQuery Carousel object interacts with other Plug-ins, and how to combine those plug-ins with the Carousel functionality.  I also cover an issue where the jCarousel plug-in does not apply functionality to non visible elements when the page loads.
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>RIA</category>
				
				<category>Json</category>
				
				<category>AJAX</category>
				
				<pubDate>Mon, 15 Mar 2010 15:24:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/3/15/Using-other-plugins-with-the-JQuery-Carousel-Plugin-and-event-issues</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Combining persistent server side (ColdFusion) variables with client side (JQuery) values</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/2/26/Combining-persistent-server-side-ColdFusion-variables-with-client-side-JQuery-values</link>
				<description>
				
				I stumbled upon an interested dilemma recently whilst building a search engine. The results of a search are returned, and can be viewed in a list or thumbnail view. The view toggle is a uses a JQuery function, so no persistent data is stored concerning a users current viewing option. The dilemma is how do you maintain the viewing mode across page reloads, such as for pagination, or filtering of the search results?
				 [More]
				</description>
				
				
				<category>JQuery</category>
				
				<category>Development</category>
				
				<category>Coldfusion</category>
				
				<category>AJAX</category>
				
				<pubDate>Fri, 26 Feb 2010 17:27:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/2/26/Combining-persistent-server-side-ColdFusion-variables-with-client-side-JQuery-values</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Using the JQuery dataTables plugin to display dynamic data in tables: part 1</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/2/25/Using-the-JQuery-dataTables-plugin-to-display-dynamic-data-in-tables-part-1</link>
				<description>
				
				Rather than writing out long winded table code to display your data in a tabulated fashion why not use the dataTables JQuery plugin to do it for you?

In this blog entry I&apos;ll be generating tables using a JQuery plugin, but I will also be generating the JQuery code from an XML document.

The theory behind the dataTables JQuery plugin is that when the template loads it makes an AJAX request to a remotely specified template. That template returns a JSON object of data which is formatted and used in a tabular display. This means that you can perfom filtering and sort functions inline, and the JQuery simply re submits the AJAX request, receiving new JSON each time. So no refreshing.

I&apos;ll be dealing with the auto generation of the JSON back end in the second part of this article. Here is how I setup the tabular display.

Build a standard html template, including the CSS and JQuery plugins.

&lt;code&gt;

&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/transitional.dtd&quot;&gt;
&lt;html lang=&quot;en-GB&quot;&gt;
&lt;head&gt;
&lt;InvalidTag http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; lang=&quot;en&quot;&gt;
&lt;InvalidTag name=&quot;language&quot; content=&quot;en-GB&quot;&gt;

&lt;style type=&quot;text/css&quot; title=&quot;currentStyle&quot;&gt; 
	@import &quot;demo_page.css&quot;;
	@import &quot;demo_table.css&quot;;
&lt;/style&gt;

&lt;s/cript type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;s/cript type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;jquery.dataTables.js&quot;&gt;&lt;/script&gt; 

&lt;/code&gt;

Next we build our JQuery function. I wont go into massive detail about all the parameters and values being passed in here, but it is well documented on &lt;a href= http://www.datatables.net/ target=_blank&gt; http://www.datatables.net/&lt;/a&gt;.

&lt;code&gt;

&lt;s/cript type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
$(document).ready(function() {
				$(&apos;#example&apos;).dataTable( {
					&quot;bProcessing&quot;: true,
					&quot;bServerSide&quot;: true,
					&quot;sAjaxSource&quot;: &quot;content.cfm&quot;,
					&quot;aoColumns&quot;: [
{ &quot;sName&quot;: &quot;Edit&quot;, &quot;sTitle&quot;: &quot;Edit&quot;, &quot;sWidth&quot;:&quot;10%&quot;} ,
{ &quot;sName&quot;: &quot;Band&quot;, &quot;sTitle&quot;: &quot;Band&quot;} ,
{ &quot;sName&quot;: &quot;Genre&quot;,&quot;sTitle&quot;: &quot;Genre&quot;} ,
{ &quot;sTitle&quot;: &quot;Fake Column&quot;} 
],
					&quot;sPaginationType&quot;: &quot;full_numbers&quot;,
					&quot;aaSorting&quot;: [[1,&apos;asc&apos;]],
					&quot;oLanguage&quot;: {
						&quot;sLengthMenu&quot;: &quot;Page length: _MENU_&quot;,
						&quot;sSearch&quot;: &quot;Filter:&quot;
					}
				} );
			} );
&lt;/script&gt;

&lt;/code&gt;

The really important column here is the &quot;aoColumns&quot; JSON data block. This specifies what fields are returned from your AJAX call, and parameters they must adhere to.

In this example we are anticipating that we will receive four columns of data back (Edit,Band,Genre and Fake Column).

Lastly we create a table with an ID of &quot;example&quot;, as this is what the JQuery is looking for. This table must be formatted in a certain way, as the JQuery plugin will re write the specified elements.


&lt;code&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;display&quot; id=&quot;example&quot;&gt; 
&lt;thead&gt;
&lt;tr&gt;
   &lt;th&gt;Edit&lt;/th&gt;
   &lt;th&gt;Band&lt;/th&gt;
   &lt;th&gt;Genre&lt;/th&gt;
  &lt;th&gt;Fake Column&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
   &lt;tbody&gt;
   &lt;tr&gt;
       &lt;td colspan=&quot;3&quot; class=&quot;dataTables_empty&quot;&gt;Loading data from server&lt;/td&gt; 
   &lt;/tr&gt;
   &lt;/tbody&gt;
&lt;/table&gt;
&lt;/code&gt;

The code also contains the header elements that will match the returned column values from the AJAX request. The last part of the table is displayed when the data is loading.

This all works well, but to extend it further I have altered the code to read from an XML document. The XML document Is loaded when the template starts, and the data fields and attributes are read, and looped over to create the JQuery code and table headers. In this way it is a generic table display template, driven from an XML document.

The XML doc:

&lt;code&gt;

&lt;?xml version=&quot;1.0&quot;?&gt;
   &lt;form&gt;
      &lt;field sName=&quot;Edit&quot; source=&quot;data&quot; sTitle=&quot;Edit&quot; sWidth=&quot;10%&quot;&gt;Edit&lt;/field&gt;
      &lt;field sName=&quot;Band&quot; source=&quot;data&quot; sTitle=&quot;Band&quot;&gt;Band&lt;/field&gt;
      &lt;field sName=&quot;Genre&quot; source=&quot;data&quot; sTitle=&quot;Genre&quot;&gt;Genre&lt;/field&gt;
      &lt;field sName=&quot;fake column&quot; source=&quot;&quot; sTitle=&quot;Fake Column&quot;&gt;Fake column&lt;/field&gt;
   &lt;/form&gt;
&lt;/code&gt;

Read the XML file and parse it out into an Array:

&lt;code&gt;
&lt;!--- parse the xml file ---&gt;
&lt;cfset variables.xml = XMLParse(&quot;test.xml&quot;) /&gt;
&lt;!--- &lt;cfdump var=&quot;#variables.xml#&quot; label=&quot;Raw xml document&quot;&gt; ---&gt;
&lt;cfset variables.fields = XMLSearch(variables.xml,&quot;form/field&quot;)&gt;
&lt;cfset variables.totalRecords = ArrayLen(variables.fields)&gt;
&lt;/code&gt;

Use something like this to dynamically generate the JQuery and table values:

&lt;code&gt;
&lt;cfoutput&gt;
&lt;cfloop index=&quot;variables.index&quot; from=&quot;1&quot; to=&quot;#ArrayLen(variables.fields)#&quot;&gt;
   { &lt;cfif variables.fields[variables.index].XmlAttributes.source EQ &quot;data&quot;&gt;&quot;sName&quot;: &quot;#variables.fields[variables.index].XmlAttributes.sName#&quot;,&lt;/cfif&gt;
    &lt;cfif structkeyexists(variables.fields[variables.index].XmlAttributes, &apos;sTitle&apos;)&gt;&quot;sTitle&quot;: &quot;#variables.fields[variables.index].XmlAttributes.sTitle#&quot;&lt;/cfif&gt;
   &lt;cfif structkeyexists(variables.fields[variables.index].XmlAttributes, &apos;sWidth&apos;)&gt;,&quot;sWidth&quot;:&quot;#variables.fields[variables.index].XmlAttributes.sWidth#&quot;&lt;/cfif&gt;
   } &lt;cfif variables.index NEQ variables.totalRecords&gt;,&lt;/cfif&gt;
&lt;/cfloop&gt;
&lt;/cfoutput&gt;
&lt;!--- table values ---&gt;

&lt;cfoutput&gt;
  &lt;cfloop index=&quot;variables.index&quot; from=&quot;1&quot; to=&quot;#ArrayLen(variables.fields)#&quot;&gt;
    &lt;th align=&quot;left&quot;&gt;#variables.fields[variables.index].XmlText#&lt;/th&gt; 
  &lt;/cfloop&gt;
&lt;/cfoutput&gt;
&lt;/code&gt;

The JSON response is hard coded in this example, so the result will not filter or search. I&apos;ll handle that in article two.

There is a full example of this &lt;a href=http://www.mccran.co.uk/examples/datatables/ target=_blank&gt;here&lt;/a&gt;.
				
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>RIA</category>
				
				<category>Json</category>
				
				<category>AJAX</category>
				
				<pubDate>Thu, 25 Feb 2010 12:26:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/2/25/Using-the-JQuery-dataTables-plugin-to-display-dynamic-data-in-tables-part-1</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Dynamically editing web content inline, using JavaScript and AJAX</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/2/10/Dynamically-editing-web-content-inline-using-JavaScript-and-AJAX</link>
				<description>
				
				Most of us are familiar with the standard method of displaying data in a tabulated fashion, selecting a record, and populating the form that follows. What about editing the content directly into a template that mirrors the actual live version of a page?

This article examines how to edit web content directly inline, and commit it back to a server using an AJAX post request.

The main catalyst for this is that clients that use a content management system do not often have a clear image of how their content will look online. The traditional form layout for entering text does not lend itself well to representing the actual content in the format it is display in.

The aim here is to build a flexible system that allows for inline content editing, and saves it gracefully to a server based database. 

I will start by saying thank you to Peter-Paul Koch. His article here (&lt;a href=&quot;http://www.quirksmode.org/dom/cms.html&quot; target=&quot;new&quot;&gt;http://www.quirksmode.org/dom/cms.html&lt;/a&gt;) on making content editable was invaluable, and a lot of this is based on his theory.

We start by setting a value &quot;editing&quot; to false. This is the default for the page, as the user isn&apos;t editing anything when the page loads. 

&lt;code&gt;
var editing  = false;

if (document.getElementById &amp;&amp; document.createElement) {
	var butt = document.createElement(&apos;BUTTON&apos;);
	var buttext = document.createTextNode(&apos;Save&apos;);
	butt.appendChild(buttext);
	butt.onclick = saveEdit;
}

function catchIt(e) {
	if (editing) return;
	if (!document.getElementById || !document.createElement) return;
	if (!e) var obj = window.event.srcElement;
	else var obj = e.target;
	while (obj.nodeType != 1) {
		obj = obj.parentNode;
	}
	if (obj.tagName == &apos;TEXTAREA&apos; || obj.tagName == &apos;A&apos;) return;
	while (obj.nodeName != &apos;P&apos; &amp;&amp; obj.nodeName != &apos;HTML&apos;) {
		obj = obj.parentNode;
	}
	if (obj.nodeName == &apos;HTML&apos;) return;
	var x = obj.innerHTML;
	var y = document.createElement(&apos;TEXTAREA&apos;);
	var z = obj.parentNode;
	z.insertBefore(y,obj);
	z.insertBefore(butt,obj);
	z.removeChild(obj);
	y.value = x;
	y.focus();
	editing = true;
	getId(e)
}

function getId(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	thisTarget = e.target.id;
	
}

function saveEdit() {
	var area = document.getElementsByTagName(&apos;TEXTAREA&apos;)[0];
	var y = document.createElement(&apos;P&apos;);
	// set the id back to the original value as the real one is destroyed
	y.setAttribute(&apos;id&apos;, thisTarget);

	var z = area.parentNode;
	y.innerHTML = area.value;
	z.insertBefore(y,area);
	z.removeChild(area);
	z.removeChild(document.getElementsByTagName(&apos;button&apos;)[0]);
	editing = false;
	// action the server request, first var is the value, second var is the id
	saveToServer(y.innerHTML,thisTarget);
}

function saveToServer(valToCommit,fieldname) {
	//alert(valToCommit);
	$.post(&quot;view/appeals/act_commitChange.cfm&quot;, { newValue: valToCommit, field: fieldname, appeal: intId },

	function(data){
		alert(data);
	});

document.onclick = catchIt;
&lt;/code&gt;

I wont go into massive depth on a line by line basis but Peter&apos;s article does break this down a lot. The premise is that there is a function catchit(), which will intercept any click events. It will then check that the event was triggered from a &apos;P&apos; tag, which is our defining element for editable content. IE any P elements hold editable content. It will then remove the P html container, replacing it with a textarea, and re insert the P tags previous html content using the innerHTML JavaScript function.

In this way we can create editable inline textareas within the framework of our page.

The next step is to create a save function. The function &apos;saveToServer{)&apos; take several arguments. It needs the value to commit, IE what the amended text string is, and the fieldname. Each &apos;P&apos; tag has an id that I am matching to a data field. In this way if there are multiple p tags in a display they can each be attributed to a specific storage field in a database. 

Because we are destroying the &apos;P&apos; tag when we create the textarea we need to re assign the id to it when we save. We can do this by using the JavaScript function &apos;setAttribute&apos;.
The setAttribute function is used to set the value of an attribute on an object. It is typically used along with objects returned by document.getElementById to assign a new value to the object&apos;s attribute.
&lt;code&gt;
// set the id back to the original value as the real one is destroyed
y.setAttribute(&apos;id&apos;, thisTarget);
&lt;/code&gt;

If we don&apos;t do this then the recreated &apos;P&apos; tag no longer has an id attribute, so will error on any subsequent updates.

Next we use a JQuery Post function to post the values through an AJAX request.

&lt;code&gt;
$.post(&quot;commitChange.cfc&quot;, { newValue: valToCommit, field: fieldname, appeal: intId },
&lt;/code&gt;

This will post the values to the cfml CFC &quot;commitChange.cfc&quot;, which handles them in a function. 

This will allow you to perform seamless inline edits to the display layer, and commit them back to a server, so they are stored in real time.

There is an example of this &lt;a href=&quot;http://www.mccran.co.uk/examples/inline/index.cfm&quot; target=&quot;new&quot;&gt;here&lt;/a&gt;. (Minus the storing). You can track the AJAX post using a tool like charles http proxy, or firefox&apos;s firebug.

Now, to write a nice JQuery response handler to fade the returned massage in and out.
				
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>Javascript</category>
				
				<category>AJAX</category>
				
				<pubDate>Wed, 10 Feb 2010 15:30:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/2/10/Dynamically-editing-web-content-inline-using-JavaScript-and-AJAX</guid>
				
				
			</item>
			
		 	
			</channel></rss>