We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.
October CMS - AJAX framework

AJAX framework

This built-in JavaScript framework provides simple but powerful AJAX capabilities. Check out the calculator example below.


  The HTML markup for this example:

<!-- The form -->
<form role="form" data-request="onTest" data-request-update="calcresult: '#result'">
    <input type="text" value="15" name="value1">
    <select name="operation">
    <input type="text" value="5" name="value2">
    <button type="submit">Calculate</button>

<!-- The result -->
<div id="result">{% partial "calcresult" %}</div>

  The calcresult partial:

{% if result %}
    The result is {{ result }}.
{% else %}
    Click the <em>Calculate</em> button to find the answer.
{% endif %}

  The onTest PHP code:

function onTest()
    $value1 = input('value1');
    $value2 = input('value2');
    $operation = input('operation');

    switch ($operation) {
        case '+' : 
            $this['result'] = $value1 + $value2;
        case '-' : 
            $this['result'] = $value1 - $value2;
        case '*' : 
            $this['result'] = $value1 * $value2;
        default : 
            $this['result'] = $value1 / $value2;

Continue to Plugin components