Page Controller 1.0 Documentation: AJAX

Page Controller Information

Blog Entries

Check Out AFF


The Page Controller is a great place to put methods to retrieve any data for use in AJAX. Just make the method remote and set the returntype appropriately and you should be all set.

So, if your page had need of a JSON-formatted resultset of Contacts, then you could add the following method to your page controller.

<cffunction name="getContactsJSON" access="remote" returntype="query" returnformat="json" output="false">
	<cfargument name="type" type="numeric" required="true">
	<cfset var qContacts = variables.Contacts.getContacts(ContactTypeID=arguments.type)>
	<cfreturn qContacts>

Now you can simply call this method from the JavaScript for your page.

Although it isn't related to page controllers, ColdFire is a great tool if you are doing any AJAX work.