Ajax Callback
Hello everyone and welcome back to our Blog...
in this beginners Post, we will show you how you can use Ajax in your Apex application.
first of all, let us explain what is Ajax call to those who don't know.
Ajax stands for Asynchronous JavaScript And XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files. AJAX’s most appealing characteristic is its "asynchronous" nature, which means it can communicate with the server, exchange data, and update the page without having to refresh the page.
The two major features of AJAX allow you to do the following:
- Make requests to the server without reloading the page
- Receive and work with data from the server.
now every time we change the department in the select list, we will show the maximum salary and the employee number for that department. to do that we will create a new ajax callback process and write the following code:
looking at the code above, the only thing to be explained is apex_application.g_x01 which is a global variable that can be used in On Demand Ajax process, this variable will hold the passed value from the client-side to the server, in our case, it will have the Department number which we will pass it later...
in the code above, we are calling the process "Get Data" that we have already created, and we are passing an object as a second parameter. the object contains the data we want to send to the server-side and finally, we are passing another object to specify some other option like the success or error functions (in our case we are displaying the values in our items). Notice here the x01 attribute that holds the item value and will be matched with the g_x01 variable.
notice that when we change the department, the classic report will not be affected by the change until we upload the page. and this is the power of Ajax, you can update specific items or regions with no need to reload. obviously, this was a very basic example and in the future, we will talk more about Ajax callback.
- https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started
- https://docs.oracle.com/database/apex-5.1/AEAPI/apex-server-namespace.htm#GUID-45B43DB1-9601-4BD6-9B7C-6C41C35BEE49
Labels: ajax, javascript, json
7 Comments:
"Please notice that this example is just for explaining the Ajax process, you can obviously do the same in a much easier way."
You should really move this disclaimer to the top of the page and make it bold and red ;-)
Otherwise readers keep wondering while reading through it.
Thank you Jochen, I should have really wrote it on the top :). Im taking in your advice and move it...
Thanks,,
if you please can explain more when we can use it
as Jochen said we can use more easier ways
so if you please advise us when we can use it
many thanks :)
very good example showing for apex ajex callback
Apex Report --> As a developer I made 3 diff.type of reports.
how to access End User 3 diff.types of report
thanks
Mahendra - 9820401229 - India
I'd like to know the easy way. Do you have an example of that?
great pure logic...thanks.
Post a Comment
Note: Only a member of this blog may post a comment.
Subscribe to Post Comments [Atom]
<< Home