Simple sijax exapmle dont work
<p>I'm learning Python and Flask, I have very little experience, but something that is impossible.
With the usual AJAX does not have any problems, but I decided to try sijax, and even a simple example does not work. I'm sure this is due to incorrect connection and initialization, because I did git clone from the official repository git hub, and everything worked.</p>

<p>In the three examples, sijax working and initialized in one-file application, I want to use in the blueprint</p>

<p>If i click on the <code>&lt;a href="javascript://"onclick="Sijax.request('say_hi');"&gt;Say Hi!&lt;/a&gt;</code>
Traceback return : 127.0.0.1 - - [12/Sep/2016 14:19:56] "POST / HTTP/1.1" 400 -</p>

<p>app <strong>init</strong>.py</p>

<pre><code>import os
from flask import (Flask,
                   redirect,
                   url_for,
                   session)
# from flask_login import LoginManager
from flask_wtf.csrf import CsrfProtect
from os import path

from .database import db
from werkzeug.contrib.fixers import ProxyFix
import flask_sijax

import hmac
from hashlib import sha1

def create_app(config=None):
    app = Flask(__name__)
    app.config.from_object(os.environ['APP_SETTINGS'])
    app.wsgi_app = ProxyFix(app.wsgi_app)
    db.init_app(app)
    app.config["SIJAX_STATIC_PATH"] = os.path.join('.', os.path.dirname(__file__), 'static/js/sijax/')
    app.config["SIJAX_JSON_URI"] = '/static/js/sijax/json2.js'
    '''
    if app.debug == True:
        try:
            from flask_debugtoolbar import DebugToolbarExtension
            toolbar = DebugToolbarExtension(app)
        except:
            pass
    '''



    with app.test_request_context():
        db.create_all()

    from .general import controllers as general
    from .shop import controllers as shop
    from .test import controllers as test
    app.register_blueprint(shop.module)
    app.register_blueprint(general.module)
    app.register_blueprint(test.module)

    flask_sijax.Sijax(app)
    CsrfProtect(app)

    @app.template_global('csrf_token')
    def csrf_token():
        """
        Generate a token string from bytes arrays. The token in the session is user
        specific.
        """
        if "_csrf_token" not in session:
            session["_csrf_token"] = os.urandom(128)
        return hmac.new(app.secret_key, session["_csrf_token"],
                        digestmod=sha1).hexdigest()

    @app.route('/')
    def index():
        return redirect(url_for('test.index'))

    return app
</code></pre>

<p>test blueprint controllers.py</p>

<pre><code>from flask import (render_template,
                   Blueprint,
                   g)

import flask_sijax

module = Blueprint('test',
                   __name__)

@flask_sijax.route(module, '/')
def index():
    def say_hi(obj_response):
        obj_response.alert('Hi there!')

    if g.sijax.is_sijax_request:
        g.sijax.register_callback('say_hi', say_hi)
        return g.sijax.process_request()

    return render_template('test/hello.html')
</code></pre>

<p>template hello.html</p>

<pre><code>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="{{ url_for('static', filename='js/sijax/sijax.js') }}"&gt;&lt;/script&gt;
    &lt;script src="{{ url_for('static', filename='js/sijax/json2.js') }}"&gt;&lt;/script&gt;
    &lt;script&gt;{{ g.sijax.get_js()|safe }}&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
    &lt;a href="javascript://" onclick="Sijax.request('say_hi');"&gt;Say Hi!&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The reason was not working sijax, it was the fact that the {{csrf_token ()}} was not active</p>

<p>It is necessary to do so either: <code>&lt;a href="javascript://" onclick="Sijax.request('say_hi', { data: { csrf_token: '{{ csrf_token() }}' } });"&gt;Say Hi!&lt;/a&gt;</code></p>

<p>Either connect to the html file:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var csrfToken = "{{ csrf_token() }}"
&lt;/script&gt;
</code></pre>

python flask sijax