Class: Form.Request

Updates a DOM element with the response from the submission of a form (via Ajax).


Form.Request Method: constructor


new Form.Request(form, update[, options]);


  1. form - (mixed) A form Element or the string id of a form Element to manage submissions.
  2. update - (mixed) An Element or the string id of an Element to update with the response.
  3. options - (object, optional) The options object described below:


  • requestOptions - (object) The options passed on to the instance of [Request.HTML] created by the class that sends the form. Defaults to {evalScripts: true, useSpinner: true, url: , emulation: false, spinnerTarget: }.
  • extraData - (object) An optional set of key/value pairs to be included with the form data submitted to the server. If keys in this collide with data in the form, the form values will be preserved and the extraData discarded.
  • resetForm - (boolean) If true (the default), the form is reset when the request is sent.


  • onSend - (function) The function to execute when the request is sent. Passed the form being submitted and the data (an object) being submited.
  • onFailure - (function) The function to execute when the request fails. Passed the xhr that is returned by Request on failure.
  • onSuccess - (function) The function to execute when the request succeeds. Passed the target being updated, the response tree, the response elements, the html (with any inline JavaScript removed), and any JavaScript that was in that html. These are the same arguments passed to Request.HTML on success, with the updated element prepended to that arguments list.

Form.Request and Form.Validator

Form.Request integrates with Form.Validator to prevent the ajax being sent if the validation fails. It retrieves the Form.Validator instance from the form, so all that is required is that you instantiate the Form.Validator before you instantiate the instance of Fudpate. If the instance of Form.Validator has the stopOnFailure option set to true (the default) then Form.Request will not send the ajax request if the validator fails.

Form.Request Method: send

Sends the form.




Form.Request Method: disable

Detaches the Form.Request from the form (disabling the ajax).




Form.Request Method: enable

Attaches the Form.Request to the form (enabling the ajax). Note that this is done on instantiation, so you only need to use this method if you disable the Form.Request instance and want to re-enable it.




This documentation is released under a Attribution-NonCommercial-ShareAlike 3.0 License.