AjaxCommunication

class visualife.widget.AjaxCommunication(url, on_complete=None, req_type='POST')

Bases: visualife.widget.ProcessData

Class that sends data with AJAX

Constructor creates a sender object

Parameters:
  • url – where the data is to be sent
  • on_complete – callback method called when transfer is completed if None, a default callback will be used that just prints a log message on the console
  • req_type – request type: “POST” or “GET”

Methods Summary

__call__(*args, **kwargs) Sends the given data with AJAX
on_complete(on_complete_func) Sets new callback function that will be called when server returns from AJAX call

Methods Documentation

__call__(*args, **kwargs)

Sends the given data with AJAX

Parameters:
  • args – data to be sent: - if args contain a single element which is a Python dictionary: the dictionary is sent ‘as it is’ - if args contain a single element: it will be stored in a JSON dictionary under ‘data’ key - if args contain more than one element: all elements will be stored in a JSON dictionary under ‘data’ key
  • kwargs – see below
Returns:

None

Keyword Arguments:
 
  • key (string) – key string will be added to JSON dictionary sent by this method
  • file_name (string) – file_name will be added to JSON dictionary sent by this method
  • response_type (string) – only one of the following: arraybuffer, blob, document, json
    or text; default is text
on_complete(on_complete_func)

Sets new callback function that will be called when server returns from AJAX call

Parameters:on_complete_func – a function name
Returns:None