data-raw, data-raw-type

Set the request body manually.


If you need to do a REST call using ajax, you will need this option to set the body manually. You'll also need to specify the body's content type using data-raw-type (xml, json, script or html), and eventually, don't forget to look at data-method to set the HTTP method to use (GET, PUT, DELETE and so on).

data-raw overwrites data-input and data-input-attr options.

Usage


  • data-raw="(selector or raw data)"
  • data-raw-type="(raw body's content type)"

Example


  • data-raw="{'Hello,':'world!'}"
  • data-raw-type="json"

Live examples

This form looks like this:


<div id="inputs">
    <input
            type="button"
            value="Click to get some raw data..."
            class="btn domajax click"
            data-endpoint="raw-simple-handler.php"
            data-raw="Hello, world!"
            data-raw-type="text"
            data-output="#output"
            />
</div>

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

This form looks like this:


<div id="inputs">
    <label for="text">Enter some text</label>
    <input type="text" id="text" name="text" value="Hello, world!"/>
    <br/>
    <input
            type="button"
            value="Send"
            class="btn domajax click"
            data-endpoint="raw-user-handler.php"
            data-raw="#text"
            data-output="#output"
            />
</div>

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

This form looks like this:


<label for="insert">Enter an element</label>
<input type="text" id="insert" name="insert"/>
<br/>
<input
    type="button"
    value="Store"
    class="btn domajax click"
    data-endpoint="raw-rest-handler.php"
    data-method="put"
    data-raw="#insert"
    data-output="#contents"
    />

<br/><br/>

<div id="contents">
    <?php include "raw-rest-handler.php"; ?>
</div>


See also    data-method 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax