dhx.proxy is a DHTMLX Touch component allowing you to send web requests via the proxy object. It defines a 'medium' data storage (cookie, session or local) that will keep the latest successful data files (further referred as 'the latest copy') and unsuccessful web requests.
dhx.proxy is an easy-to-use component. All you need to do is to instantiate it and specify the instance as the url parameter of the component(s) that will take data from the server.
var source = new dhx.proxy({ url: "./data.php", storage: dhx.storage.cookie }); dhx.ui({ view:"list", id:"mylist", url: source, datatype: 'json', ... })
Related sample: ui/server/02_saving/08_dataprocessor_proxy_offine.html
dhx.proxy can be initialized in the following way:
var source = new dhx.proxy({ url: "./data.php", storage: dhx.storage.session });
The constructor takes 2 parameters:
If for connecting to the server you use dataProcessor, you should set its url parameter to a dhx.proxy object. After this all web requests start to be passed to the server through proxy.
var source = new dhx.proxy({ url: "./data.php", storage: dhx.storage.cookie }); dhx.ui({ view:"list", id:"mylist", url: source, datatype: 'json', ... }) var dp = new dhx.DataProcessor({ master:$$('mylist'), url: source });
In case you don't use dataProcessor and 'write' the server-client logic manually, you will need these 2 methods:
The methods work like normal Ajax GET and POST requests.
var source = new dhx.proxy({ url: "./data.php", storage: dhx.storage.cookie }); dhx.ui({ view:"list", id:"mylist", url: source, datatype: 'json', ... }) var params = ["a=1", "b=2"]; // request parameters list source.post( params.join('&'), { success: function() { moveItem(id, $$('mylist'), $$('ready_list')); }, error: function() { moveItem(id, $$('mylist'), $$('proxy_list')); } });