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.
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> <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>
All the documentation at a glance