Edit this page

up.protocol X-Up-Fail-Target
HTTP header

This request header contains the CSS selector targeted for a failed fragment update.

A fragment update is considered failed if the server responds with a status code other than 2xx, but still renders HTML.

Server-side code is free to optimize its response to a failed request by only rendering HTML that matches the provided selector. For example, you might prefer to not render an expensive sidebar if the sidebar is not targeted.

The user may choose to not send this header by configuring up.network.config.requestMetaKeys.


X-Up-Target: .menu
X-Up-Fail-Target: body

Signaling failed form submissions

When submitting a form via AJAX Unpoly needs to know whether the form submission has failed (to update the form with validation errors) or succeeded (to update the [up-target] selector).

For Unpoly to be able to detect a failed form submission, the response must be return a non-2xx HTTP status code. We recommend to use either 400 (bad request) or 422 (unprocessable entity).

To do so in Ruby on Rails, pass a :status option to render:

class UsersController < ApplicationController

  def create
    user_params = params[:user].permit(:email, :password)
    @user = User.new(user_params)
    if @user.save?
      sign_in @user
      render 'form', status: :bad_request

This website uses cookies to improve usability and analyze traffic.
I accept or learn more