![]() Helper for fetching a CSRF token: const getSessionInfo = function ( ), in the example) whose values aren’t yet known.įor JSON responses, redirection does’t make as much sense-so Craft will include the resolved redirect value for your client to navigate programmatically (say, via window.location = resp.redirect). Some tools (like jQuery) need no configuration others (like the native fetch() API (opens new window)) will need to be configured explicitly: In order to respond appropriately, Craft requires that Ajax requests are identified as such. Override success-condition flash messages. Generates a hidden HTML element to control redirection after successful requests. Lower-level helper for generating hidden HTML inputs.Įven finer-grained control over HTML element creation. Generate a hidden HTML required for CSRF protection. Generate an absolute URL to the specified action, with any extra params. Generate a hidden HTML element for controlling which action a should route to. # POSTĪll POST requests are made through forms or Ajax, and require an action parameter and CSRF token. Using an unsupported method will throw a yii\web\BadRequestHttpException (opens new window), and show your error template with a 400 statusCode-or send a JSON response with an error key. ![]() # HTTP VerbsĮach action usually responds to one HTTP method (opens new window). This attribute has no effect if a redirect is issued in response to the request!Ĭraft also supports routing to specific actions using a path (beginning with the actionTrigger setting), or by creating an rule in routes.php. When an action param is not present in the request, you can use an “action path” like action="/actions/users/login". The form attribute should only be used when you want to control where a user is sent in failure scenarios.The action param should be used within a URL query string ( ?action=.) for GET requests, or in the body of a POST request.This action parameter is different from the attribute:
0 Comments
Leave a Reply. |