Ajax calling in Oracle Application Express (APEX 4.2)
Oracle Application Express 4.2 (APEX 4.2) is a quick Web Application development tool. Ajax requests are sometimes used during web page development.
How to create an ajax request:
1. Create background processing:
Step 1
Step 2
Step 3
In this way, the background processing is completed.
2. Compile js on the frontend:
Function ajaxTest (){
Apex. server. process ('test', // name of the background processing, case sensitive
{}, // Parameters to be passed
{
DataType: 'text ',
Success: function (data ){
Console. log (data );
}
}
);
}
AjaxTest ();
In this way, the console outputs hello world.
PS:
If you want to pass parameters, you can do this:
Apex. server. process ('test', // name of the background processing, case sensitive
{
// The x01-x10 is a public variable built in apex that can pass General strings.
X01: 'param1 ',
X02: 'param2 ',
...
X10: 'param10 ',
// If there are many variables to be passed and the types are the same, you can use an array
F01: ['param1', 'param2',...],
F02: [...]
},
{
DataType: 'text ',
Success: function (data ){
Console. log (data );
}
}
);
Plsql reference in background processing
Declare
Rochelle str1 varchar2 (20 );
Rochelle str2 varchar2 (20 );
Begin
Rochelle str1: = apex_application.g_x01;
Rochelle str2: = apex_application.g_f01 (1); -- note that the start of plsql numbers is 1.
End;
This article permanently updates the link address: