Feb. 10th 2008
Released: JSMX v2.6.4 (Code Enhancements)
Feb. 6th 2007
Released: JSMX v2.6.3 (UTF-8 support)
Mar. 25th 2006
Help advance the JSMX technology by making a donation.
What is JSMX?top
But ColdFusion developers aren't the only ones who can take advantage of this small but powerful API. JSMX has been extended to support XML, JSON, and now WDDX while remaining completely backward compatible to it's original user base. With no Server Side Modules to install and with so many data-exchange options, JSMX is now the perfect choice for fast Ajax integration for ANY language.
How Does JSMX Work?top
The beauty of this API is its simplicity and its straight forward syntax. It consists of just one file (engine.js) which marshals requests between the client and the server via the http() function (which is the only function you need to know about in order to use JSMX).
Making the Requesttop
Let’s take a look at how to make requests to the server using JSMX. As mentioned above we do this via the http() function. Below is the basic syntax.
Syntax: http( verb , url , callback [, params] )
|verb||(required)||"Get" or "Post"|
|url||(required)||"any server-side file (cfc, cfm, php, aspx, jsp, etc...)"|
|callback||(required)||"reference to any function you want the response passed to"|
|params||(optional)||"used to pass parameters to the server when verb = 'POST'"|
Parameters can be passed to the server in any one of the following three formats:
Handling the Responsetop
- what server language you are using
- what data-exchange methodologies are you most familiar with
- will your server-side code be consumed by Ajax only, or will it also be consumed by other external processes such as Flash Remoting Application or a Web Service.
Below is a brief comparison of each option. You can also navigate to the examples page to get a better idea of how to use JSMX.
- Booleans and numbers are treated as strings in. This means ToScript(true,"r") will produce r="true"; NOT r=true;
- All variables will be passed back in lowercase regardless of the case used in ColdFusion: myStruct.customerId will become mystruct.customerid
WDDX or (Web Distributed Data eXchange) is an XML based specification which allows you to exchange data. Like JSON it is not a W3C standard, but it is an open source methodology and is natively supported in ColdFusion as well as being supported by several other languages such as PHP, JSP, Pearl, Visual Basic, etc…. Of all the Data-Exchange options within JSMX, WDDX is probably the most verbose, but it does have its advantages. To learn more about WDDX or to download the SDK, visit www.openWDDX.org
One advantage worth noting applies to ColdFusion developers using ColdFusion Components. When calling a function inside of a component directly through a URL (such as how you would call it using JSMX), ColdFusion will automatically return the data to you as a WDDX packet if you return your data via the <CFRETURN> tag. This means, JSMX can consume the same functions exposed to a Flash Remoting application or Web Service already existing on your ColdFusion Server, without the need of building a "proxy" function.