data-method

Change the HTTP method used to reach the endpoint

data-method lets you change the HTTP method used to reach the endpoint. Default method is POST, but by using this option, you can change it to GET, PUT, DELETE or whatever you need.

By default, if data-method is not set, the HTTP POST method will be used.

Usage


  • data-method="method-to-use"

Example


  • data-method="get"
  • data-method="put"
  • data-method="delete"

Live examples

This form looks like this:


<div id="inputs">

    <input
            type="button"
            value="Click to test data-method=&quot;get&quot;"
            class="btn domajax click"
            data-method="get"
            data-endpoint="method-buttons-handler.php"
            data-input="#inputs"
            data-output="#output"
            />

    <br/><br/>

    <input
            type="button"
            value="Click to test data-method=&quot;post&quot;"
            class="btn domajax click"
            data-method="post"
            data-endpoint="method-buttons-handler.php"
            data-input="#inputs"
            data-output="#output"
            />

    <br/><br/>

    <input
            type="button"
            value="Click to test the default behaviour if data-method is missing"
            class="btn domajax click"
            data-endpoint="method-buttons-handler.php"
            data-input="#inputs"
            data-output="#output"
            />

</div>

<br/>

<div id="output"></div>

This form looks like this:


Enter a variable name:
<br/>
<input type="text" id="variable" name="variable"/>

<br/><br/>

<input
        type="button"
        value="Create"
        class="btn domajax click"
        data-endpoint="method-rest-handler.php"
        data-raw="#variable"
        data-raw-type="text"
        data-output="#output"
        data-method="put"
        />

&nbsp;

<input
        type="button"
        value="Delete"
        class="btn domajax click"
        data-endpoint="method-rest-handler.php"
        data-raw="#variable"
        data-raw-type="text"
        data-output="#output"
        data-method="delete"
        />

&nbsp;

<input
        type="button"
        value="List"
        class="btn domajax click"
        data-endpoint="method-rest-handler.php"
        data-raw="#variable"
        data-raw-type="text"
        data-output="#output"
        data-method="options"
        />

<br/><br/>

<input
        type="button"
        value="Increment"
        class="btn domajax click"
        data-endpoint="method-rest-handler.php"
        data-raw="#variable"
        data-raw-type="text"
        data-output="#output"
        data-method="post"
        />

&nbsp;

<input
        type="button"
        value="Get value"
        class="btn domajax click"
        data-endpoint="method-rest-handler.php"
        data-raw="#variable"
        data-raw-type="text"
        data-output="#output"
        data-method="get"
        />

&nbsp;

<input
        type="button"
        value="Decrement"
        class="btn domajax click"
        data-endpoint="method-rest-handler.php"
        data-raw="#variable"
        data-raw-type="text"
        data-output="#output"
        data-method="head"
        />

<br/><br/>

<div id="output"></div>


See also    data-raw 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax