There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.
Close

Processing...
This may take a few seconds.

ajax-form-submit

Syntax

ajax-form-submit: [method] [return type] [get-pars(parameters)] [post-pars(parameters)] [cache] [every (time)] [after (time)][, ...];

New: as of version 2.13.0, regular HTML file uploads are supported.

This command submits the form designated by the target selector by an ajax call. The following variables will be found on the server (in GET or POST form depending on the method of the ajax call) when the form is submitted:

  • _ACSS = 1
  • _ACSSFORMSUBMIT = 1
  • _ACSSTYPE = JSON or HTML

The command accepts the following parameters:

method = post or get (defaults to post)

return type
= json or html (defaults to json)
The browser will expect either a json string as a return value from the server, or an html (text) string. See the afterAjax event on how to handle the returned values of html or json.

parameters = any variables that you want to send with the ajax call, separated by &

get-pars = Parameters using get-pars will be sent to the url on the url itself.

The following example will ajax submit all the form variables via POST and send the variables myVar=1 and myVar2=test on the URL as GET variables. Whether or not to use a "?" is handled internally:

#mySubmitButton:click {
    #myForm {
        ajax-form-submit: html post get-pars(myVar=1&myVar2=test);
    }
}

post-pars = Parameters using post-pars will be sent as POST parameters when the form is submitted.

The following example will submit the form via GET and also include the variables myVar=1 and myVar2=test as POST variables. Whether or not to use a "?" is handled internally:

#mySubmitButton:click {
    #myForm {
        ajax-form-submit: get post-pars(myVar=1&myVar2=test);
    }
}

If you want to see what is actually happening with your ajax command, use the console in your default browser inspector to see what is actually being sent and how. This is the best way to debug if variables are being sent or not, and whether or not they should be being received on the server as GET or POST variables.

cache = Store this unique form submit request (including all variables) and its response so it will not be retrieved from the server for the remainder of this page. The cache is only for the duration of the loaded page. Ie. if the browser is refreshed, there will no requests in memory. There is no attachment of the request to internal storage. This is useful if you want to send a search query and not do it more than once if it will have the same return values.