data-output-json

Dispatch an ajax JSON response to several parts of a page

If your ajax response needs to refresh several parts of the page, you will send it as json from server side. Configure your domajax call to associate a json attribute to an output selector, and domajax will automatically dispatch your results to their right containers.

Usage


  • data-output-json="attr-A attr-B"
  • data-json-attr-A="#outputA"
  • data-json-attr-B="#outputB"

Example


  • data-output-json="message result"
  • data-json-message="#msg"
  • data-json-result="#contents"

Live examples

This form looks like this:


<input
        type="button"
        value="Get the time"
        class="btn domajax click"
        data-endpoint="output-json-clock-handler.php"
        data-output="#output"
        data-output-json="year month day hour min sec"
        data-json-year="#year-container"
        data-json-month="#month-container"
        data-json-day="#day-container"
        data-json-hour="#hour-container"
        data-json-min="#min-container"
        data-json-sec="#sec-container"
        />

<br/><br/>

<span id="day-container" style="color: blue">??</span> /
<span id="month-container" style="color: green">??</span> /
<span id="year-container" style="color: red">????</span> &nbsp;
<span id="hour-container" style="color: orange">??</span> :
<span id="min-container" style="color: pink">??</span> :
<span id="sec-container" style="color: yellow">??</span>

<br/><br/>

<p>Raw output:</p>

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


See also    data-output   data-callback   data-script 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax