• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 506
  • Last Modified:

Converting a mysql query to xml for spry or ajax in Coldfusion

Hi Experts!

I have a grip on CF and MySQL.  I don't have a grip on XML.

I need to go from a mysql query to spry or ajax.  Is it even possible to do?  Am I doomed?
  • 5
  • 3
2 Solutions
ImWorkingOnItNowAuthor Commented:
It certainly does.  Thanks for posting.

Would that be an xml file or a cfm file?
XML is totally different than ajax / older spry (both javascript).  What exactly do you need to do?
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

ImWorkingOnItNowAuthor Commented:
Hi _aqx_!

Right now, all I need to do is create a dynamic table and a "check for availability" button for a login form.  I've always been curious about how to get from mysql to xml.
You don't have to tie yourself to spry specifically.  There's lots of different implementations.  Binding, jquery, etc..  All you need is a javascript/ajax call to send info to a CFC (or .cfm page). Then parse the response returned from the CFC.

Here's an example using CF/jquery

Another using bindings

There's also bunches of examples in the docs, like this one

    function submitForm() { 
    function onCompleteHandler(text) { 
    	var result = ColdFusion.JSON.decode(text);
    	if (!result.isAvailable) {
        	alert("Sorry! The name "+ result.loginName +" is already in use"); 
    	else {
        	alert("The name "+ result.loginName +" is available!"); 
    function onErrorHandler(code, msg) { 
        alert("Error!!! " + code + ": " + msg); 
 <form name="loginForm"> 
    login <input type="text" name="loginName" value="John"> 
 <a href="javascript:submitForm()">Submit form</a> 

Open in new window

    <cffunction name="checkAvailability" access="remote" output="false" returntype="struct" returnformat="json">
        <cfargument name="loginName" type="string" required="false">
		<cfset var result = {}>
		<cfset result["isAvailable"] = true >
		<cfset result["loginName"] 	 = arguments.loginName >

		<!--- for testing, name "john" is already in use --->
		<cfif arguments.loginName eq "john">       
			<cfset result["isAvailable"] = false >
        <cfreturn result>

Open in new window

I've always been curious about how to get from mysql to xml.

Technically you don't need xml for this type of task.  JSON format works just as well.
ImWorkingOnItNowAuthor Commented:
Is there ever a reason to do this?
Not sure I follow.  There are reasons to do most things if you search hard enough ;-) But usually it's the other way around: ie I am faced with problem "XYZ", what techniques will help me solve it?

.. in other words, are you asking generally "how would I convert query results to XML"  OR is it a specific problem you're trying to solve like:  create a "check for availability" button for a login form?  

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now