Send onClick

When you need to send data to the server when an element is clicked, this is your solution.

Any element can be used to achieve this functionality. All need is a class addition called send-to-server-click, additional options are passed via attributes.

Attribute options are;

  • loader

    • Optional

    • "true" or "false"

    • when true, a loader will be shown when button is clicked and hidden when set false.

  • url

    • required

    • url

    • the path to where the form will be submitted

  • data

    • required

    • string. example username:johnd|name:John Doe|email:john@example.com. Separate a key from value with full colon : and separate each group with |

  • warning-title

    • optional

    • Warning title to warn user when needed

  • warning-message

    • optional

    • Warning title to warn user when needed

  • warning-button

    • optional

    • The label of the warning button.

usage

<button class="send-to-server-click" data="username:johnd|name:John Doe|email:john@example.com" url="https://example.com/server" warning-title="Are you sure?" warning-message="This process is irreversable" warning-button="Continue" loader="true">Empty Now</button>

Response

Responses should be JSON, please refer to the server response page for more information.

Server Responses

Last updated