Based on frequent questions about working with DHTMLX and Ajax, we decided to explain how it works in detail.
The main function of Ajax is interaction with a server, sending requests and processing of user data in particular. dhtmlxAjax was simplified in the version 4.0.
The general scripts of working with Ajax are the following:
- data request from the server
- processing of the server response
- error handling
We’ll use PHP as a server script, but in general any server script can generate the content.
The first param is the address of the server script server.php, there also can be any number of additional parameters p1=v1, p2=v2 (but don’t forget about the limit of GET request). As GET is an asynchronous request, we need the second param – a function that is called after the response is loaded (we’ll talk about it later).
POST request is similar to GET, but here we pass the parameters as a separate argument:
So, the data are requested by client. Now let’s see how to process them on the server and create a response for the client side. The most secure way is to pass data by means of using some structure, e.g. json or xml. Why them? These formats are described and they are the same in any environment. We won’t show the business logic operations in our example, just the received result.
Read more »