#62002/4/16 15:00:32
看看吧
function postWithNamedArgs()
{
// Setup the array of post parameters.
params = new Array();
params[1] = {name:"arg1", type:"FormField", value:"value1"};
params[2] = {name:"arg2", type:"URL", value:"value2"};
params[3] = {name:"arg3", type:"CGI", value:"value3"};
url = "http://localhost:8100/";
path = application.getContext("/").getRealPath("/");
file = "foo.txt";
result = CF.http({method:"post", url:url, username:"karl", password:"salsa",
resolveurl:true, params:params, path:path, file:file});
if (result)
return result.get("Statuscode");
return null;
}
// Example of a basic HTTP get operation
// Shows that get is the default
function basicGet()
{
url = "http://localhost:8100/";
// Invoke with just the url. This is an http get.
result = CF.http(url);
return result.get("Filecontent");
}
// Example showing simple array created to pass params arguments
function postWithParams()
{
// Setup 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:8100/";
// Invoke with the method, url, and params
result = CF.http("post", url, params);
return result.get("Filecontent");
}
// Example with username and params arguments
function postWithParamsAndUser()
{
// Setup 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:8100/";
// Invoke with the method, url, params, username, and password
result = CF.http("post", url, params, "karl", "salsa");
return result.get("Filecontent");
}
编辑历史:[这消息被jaway编辑过(编辑时间2002-04-16 15:01:20)]
[这消息被jaway编辑过(编辑时间2002-04-16 19:33:30)]