22.08.2013 Views

ColdFusion Developer's Guide

ColdFusion Developer's Guide

ColdFusion Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />

For example, when you build an HTML form using the Post method, you specify the name<br />

of the page to which form data is passed. You use the Post method in the CF.http function<br />

in a similar way. However, with the CF.http function, the page that receives the Post does not<br />

display anything. See the following example:<br />

function postWithParams()<br />

{<br />

// Set up the array of Post parameters. These are just like cfhttpparam<br />

tags.<br />

// This example passes formfield data to a specified URL.<br />

params = new Array();<br />

params[1] = {name:"Formfield1", type:"FormField", value:"George"};<br />

params[2] = [name:"Formfield2", type:"FormField", value:"Brown"};<br />

}<br />

url = "http://localhost:8500/";<br />

// Invoke CF.http with the method, url, and params<br />

result = CF.http("post", url, params);<br />

return result.get("Filecontent");<br />

Using the CF.http Get method<br />

You use the Get method to retrieve files, including text and binary files, from a specified<br />

server. You reference properties of the object returned by the CF.http function to access<br />

things like file content, header information, MIME type, and so on.<br />

The following example uses the CF.http function to show a common approach to retrieving<br />

data from the web:<br />

// Returns content of URL defined in url variable<br />

// This example uses positional argument style<br />

function get()<br />

{<br />

url = "http://www.adobe.com/software/coldfusion/";<br />

//Invoke with just the url argument. Get is the default.<br />

result = CF.http(url);<br />

return result.get("Filecontent");<br />

}<br />

For more information about CF.http function properties, see CF.http in CFML Reference.<br />

1026 Using Server-Side ActionScript

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!