CFAjax

techscreencast.com
(Quality Technical Screencast)
Coldfusion Projects

Basic requirments for CFAjax
On server Side : Coldfusion 6.0 and above
On Client Side : Javascript Should be enabled, and Browser should support XML Http object


CFAjax licence
CFAjax is an open source product, you are free to use and distribute CFAjax with your applications. All we request is to let us know if you are using CFAjax in your application so that we can maintain a master list of all the CFAjax users and help us promote this project.


What all browser does CFAjax supports
CFAjax supports IE and firefox. but other browser's that provide xmlhttp object and javascript support can also used CFAjax.


Can i use CFAjax to request data from another server
By default CFAjax uses the HTTP POST to retrieve the data, but if you try to access the data from some other site other then the site that rendered the page, Browser will show a "Security voilation" Popoup, in order to get over this issue you can use the HTTP GET method, instead of the default POST method, below is the code snipppet that should be put in the HMTL page.

		<script language="javascript">
			DWREngine.setVerb("GET"); //default is POST
		</script>
	


How can i fill html drop down and pouplated both value and text field
You can return data from CF in multiple ways that can be used to pouplate text and value attributes of drop down box

Example 1 : Returning a Coldfusion Structure
In your Coldfusion code you can create a CF structure like this and return it back to the html page.

	<cfset retStruct = StructNew()>
	<cfset StructInsert(retStruct, "10, Tenth Grade")>
	<cfset StructInsert(retStruct, "5, 5th Grade")>
	<cfset StructInsert(retStruct, "1, 1st Grade")>
	
Example 2 : Returning a Array       Key Value sample uses this approach
If you are returning an array and want it populate key value of dropdown list you will have to provide the hint attribute in your CF function to let CFAjax know that this array needs special treatment. Function should be defined like this
<cffunction name="functionname" hint="type='keyvalue' jsreturn='array'"> and the CF code should create the array like this
	<cfset retArr = ArrayNew(1)>
	<cfset ArrayAppend(standingArray, "10, Tenth Grade")>
	<cfset ArrayAppend(standingArray, "5, 5th Grade")>
	<cfset ArrayAppend(standingArray, "1, 1st Grade")>
	
Example 3 : Returning a List
If you are returning an List and want it populate key value of dropdown list you will have to provide the hint attribute in your CF function to let CFAjax know that this List needs special treatment. Function should be defined like this
<cffunction name="functionname" hint="type='keyvalue' jsreturn='array'"> and the CF code should create the array like this
	<cfset retList = "">
	<cfset retList = ListAppend(retList, "10=Tenth Grade")>
	<cfset retList = ListAppend(retList, "5=5th Grade")>
	<cfset retList = ListAppend(retList, "1=1st Grade")>