|
|
Sijax stands for ‘Simple Ajax’ which is a Python/jQuery library designed to bring Ajax to the application. It uses jQuery.ajax for making AJAX requests.
Installation of Flask-Sijax is easy.
Sijax uses JSON for passing data between the browser and the server which means that the browsers either has to support JSON natively or get JSON support from the json2.js file. Functions registered in that way will not provide Sijax functionality as they cannot be accessed using a POST method by default (and Sijax uses POST requests).
For making a View function capable of handling Sijax requests, make it accessible via POST using @app.route('/url', methods = ['GET', 'POST']) or use the @flask_sijax.route helper decorator like this
Every single Sijax handler function will receive at least one parameter automatically, like Python passes ‘self’ to the object methods. ‘obj_response’ parameter is the function's way of talking back to the browser.
When Sijax request is detected, Sijax handles it as shown below
A minimal Sijax application code looks as shown below
When a Sijax requests (a special jQuery.ajax() request) to the server, this request will be detected on the server by g.sijax.is_sijax_request() and allows Sijax to handle the request. All the functions registered using g.sijax.register_callback() will be exposed for calling from the browser. Calling g.sijax.process_request() tells Sijax to execute appropriate (previously registered) function and return the response to the browser.
|
|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.