| Contents > Developing ColdFusion MX Applications > Using XML and WDDX > Using WDDX > Converting CFML data to a JavaScript object |
|
|
|
|
||
The following example demonstrates the transfer of a cfquery recordset from a ColdFusion page executing on the server to a JavaScript object that is processed by the browser.
The application consists of four principal sections:
The following example uses the cfsnippets data source that is installed with ColdFusion:
<!--- Create a simple query ---> <cfquery name = "q" datasource ="cfsnippets"> SELECT Message_Id, Thread_id, Username, Posted FROM messages </cfquery> <!--- Load the wddx.js file, which includes the dump function ---> <script type="text/javascript" src="/CFIDE/scripts/wddx.js"></script> <script> // Use WDDX to move from CFML data to JavaScript <cfwddx action="cfml2js" input="#q#" topLevelVariable="qj"> // Dump the recordset to show that all the data has reached // the client successfully. document.write(qj.dump(true)); </script>
Note: To see how cfwddx Action="cfml2js" works, save this code under your webroot directory, for example in wwwroot/myapps/wddxjavascript.cfm, run the page in your browser and select View Source in your browser.
|
|
||
| Contents > Developing ColdFusion MX Applications > Using XML and WDDX > Using WDDX > Converting CFML data to a JavaScript object |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.