Adobe ColdFusion 8

ColdFusion.Ajax.submitForm

View comments | RSS feed

Description

Submits form data without refreshing the page when the results are returned.

Function syntax

ColdFusion.Ajax.submitForm(formId, URL[, callbackhandler, errorhandler, httpMethod, asynch])

See also

cfajaxproxy, ColdFusion.navigate, "Using the ColdFusion.Ajax.submitForm function" in the ColdFusion Developer's Guide

History

ColdFusion 8: Added this function

Parameters

Parameter

Description

formId

The ID or name attribute of the form.

URL

The URL to which to submit the form.

callbackhandler

The JavaScript function to handle a normal response. The function must take a single argument, that contains the response body. This method is used only if the form submission is asynchronous.

errorhandler

The JavaScript function to handle an HTTP error response. The function must take two arguments: the HTTP status code, and the error message. This method is used only if the form submission is asynchronous.

httpMethod

The HTTP method to use for the submission, must be one of the following:

  • GET
  • POST (the default)
asynch

A Boolean value specifying whether to submit the form asynchronously. The default value is true.

Returns

If the asynch argument is false, returns the response body. Otherwise, the function does not return a value.

Usage

If the page that calls this function does not have any ColdFusion AJAX-based controls, you must use a cfajaximport tag on the page to ensure that the page includes the JavaScript definition for this function.

Note: This function does not submit the contents of file fields.

Example

See "Using the ColdFusion.Ajax.submitForm function" in the ColdFusion Developer's Guide.



Comments


No screen name said on Aug 27, 2007 at 12:49 PM :
It seems that if you need to upload a file in a form using this funciton, you cannot do so. I think it is because the content-type is application/x-www-form-urlencoded based off the cfajax.js file.

You need the content-type to be multipart/form-data. I tried to switch it in the cfajax.js file, but it just gave me an internal server error

--Michael
halL said on Aug 30, 2007 at 5:39 AM :
When you use Ajax form submission to submit forms asynchronously from the page, you cannot use cfinput type="file" to upload a file.
This is because the XMLHttpRequest object, which is used for the submission, does not support it.
You must use a custom Ajax file upload component to upload a file using an Ajax form.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/8/htmldocs/JavaScriptFcns_03.html