
701
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
In the following example, the
CF.http
function passes HTTP
Post
parameters in an array of objects:
function postWithParamsAndUser()
{
// Set up the array of Post parameters. These are just like cfhttpparam tags.
params = new Array();
params[1] = {name:"arg2", type:"URL", value:"value2"};
url = "http://localhost:8500/";
// Invoke with the method, url, params, username, and password
result = CF.http("post", url, params, "karl", "salsa");
return result.get("Filecontent");
}
Using the CF.http Post method
You use the
Post
method to send cookie, form field, CGI, URL, and file variables to a specified ColdFusion page or CGI
program for processing. For POST operations, use the
params
argument for each variable that you post. The
Post
method
passes data to a specified ColdFusion page or an executable that interprets the variables being sent, and returns data.
For example, when you build an HTML form using the
Post
method, you specify the name of the page to which form
data is passed. You use the
Post
method in the
CF.http
function in a similar way. However, with the
CF.http
function, the page that receives the Post does not display anything. See the following example:
function postWithParams()
{
// Set up the array of Post parameters. These are just like cfhttpparam tags.
// This example passes formfield data to a specified URL.
params = new Array();
params[1] = {name:"Formfield1", type:"FormField", value:"George"};
params[2] = [name:"Formfield2", type:"FormField", value:"Brown"};
url = "http://localhost:8500/";
// Invoke CF.http with the method, url, and params
result = CF.http("post", url, params);
return result.get("Filecontent");
}
Parameter
Description
name
The variable name for data that is passed
type
Transaction type:
•
URL
•
FormField
•
Cookie
•
CGI
•
File
value
Value of URL, FormField, Cookie, File, or CGI variables that are passed