the creative internet technology co.

cfajaximport 'Coldfusion' is not defined error

Monday, 7 March 2011
A tip for anyone who's getting a "'Coldfusion' is not defined" error on Coldfusion 8/9 when using cfajaximport: check your virtual directories.

I spent some time this morning trying to work this one out but it was a simple solution in the end.

What was confusing me was that I could view the source of my CFML file in Firefox...

Snippet of 'View source' showing cfajaximport result - CLICK TO SHOW LARGER SNIPPET

...and when I clicked on the script links, I could access the corresponding code...

Snippet of 'View source' showing cfajax.js - CLICK TO SHOW LARGER SNIPPET

Yet somehow the Javascript wasn't working.

The solution was simple - although the CFIDE virtual directory was mapped correctly in Coldfusion Administrator...

Screengrab of mappings from Coldfusion Administrator - CLICK TO SHOW LARGER SNIPPET

...there was not an equivalent in IIS.

I added the virtual directory to IIS and now Bob is my proverbial uncle - cfajaximport works just fine.

Screengrab of mappings from IIS7

I'm not an expert on Apache/Tomcat etc but I suspect the same issue crops up on that platform and can be fixed similarly easily.