ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Web-specific functions / AJAX functions
  • Result of the server procedure
  • Procedures that can be called by AJAX
  • Older browsers
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
AJAXExecute (Function)
In french: AJAXExécute
Executes a server procedure without refreshing the page. This function blocks the application. No other process is run until the result of the server procedure is received.
To avoid locking the processes, use AJAXExecuteAsynchronous.
// Is AJAX supported by the current browser?
IF AJAXAvailable() = True THEN
	// Run the server procedure named "MyProc"
	Res is string
	Res = AJAXExecute(MyProc, ProductID, CustomerCity)
	// Use the data to modify 
	...
ELSE
	// Processes without using AJAX 
	... 
END
// -- MyProc server procedure // --
// Procedure used to find the data to be modified in the page 
PROCEDURE MyProc(ProductRef, CCity)
// Find data to be modified
...
// Return the result
RETURN Result1
Syntax
<Result> = AJAXExecute([<Options>, ] <WLanguage procedure> [, <Parameter 1> [... [, <Parameter N>]]])
<Result>: Character string
Result of the <WLanguage procedure>. This result contains the data to modify in the page.
<Options>: Integer constant (or combination of constants)
Refresh mode:
ajaxPostValueOfControlsThe values of all the controls of the page must be sent to the server. The WLanguage procedure called will use the values of the controls that contain data entered by the user.
ajaxStraightCall
(default value)
Modified controls are not refreshed in the page.
ajaxSynchronizeServerVariablesThe AJAX call will send variables with the <Browser synchronized> attribute.
ajaxUpdateControlsModified controls are automatically refreshed in the page.
ajaxWithoutLockingAWPContextThe AWP session is not blocked during Ajax calls, to enable parallel calls.
In this case, it is not possible to use the AWP session in server procedures.
Caution: This constant has no effect in a page or project test.

Caution: These constants must be used directly. You cannot use a variable to store their value.
<WLanguage procedure>: Procedure name
Name of the local or global server procedure to be executed. This procedure is used to find the data to be modified in the page.
The result of this procedure must be a character string returned to the browser by the RETURN keyword. For more details, see remarks.
This procedure must be allowed to be called by AJAX (see the Notes).
<Parameter 1>: Optional character string
First parameter passed to <Procedure name>.
Caution: Only simple types can be used (string, int, etc.). Structured types cannot be used.
<Parameter N>: Optional character string
Nth parameter passed to <Procedure name>.
Caution: Only simple types can be used (string, int, etc.). Structured types cannot be used.
Remarks

Result of the server procedure

<WLanguage procedure> is used to search for data to modify in the page. The result of this procedure corresponds to the data to modify.
To return this result to the browser, simply use the RETURN keyword and specify:
  • the character string that contains the data.
  • the name of the XML document that contains the data.
This result will be automatically contained in the <Result> parameter of AJAXExecute. Then, this result must be used to refresh the data to be modified.
If this result corresponds to the name of an XML document, this document will be automatically transmitted and created on the browser. Then, this document can be handled by the XML functions.
Note: In the case of an XML document:
  • the XML document is not automatically deleted from the server when it is transmitted to the browser.
  • if an XML document with the same name is already found on the browser, the new XML document automatically replaces the former one.

Procedures that can be called by AJAX

To secure the WEBDEV websites, the server procedures are protected from illegal calls (attempt to re-route a session for example). To run a server procedure from a browser process (AJAXExecute or AJAXExecuteAsynchronous), you must allow this procedure to be called by AJAX.
By default, new server procedures are set to "automatic" mode.
Automatic mode detects if there are any calls to the server procedure written in Browser code. This includes any use of the AJAXExecute function or any direct calls. The number of detected calls appears in the procedure header.
Two other modes can be enabled via the context menu of the procedure header:
  • "Always accessible from Browser code" (accessible).
  • "Never accessible from Browser code" (inaccessible).
You can force accessible mode to handle cases where calls are not automatically detected. This happens when procedures are located in external components and calls are made from the project.
You can also force inaccessible mode. In this case, the procedure can never be called from a Browser code.
Note: Procedures accessible from Browser code can be executed with malicious intent. "Inaccessible" mode provides additional security compared to automatic mode. "Automatic" mode makes the procedure inaccessible from a browser only if it has never been called from Browser code.

Older browsers

AJAXAvailable is used to determine if the current browser supports AJAX technology. If a process that uses AJAX is run on a browser that does not support this technology, the process is run "as if" it did not use AJAX (e.g., the entire page is refreshed).
Business / UI classification: Neutral code
Component: WDJS.DLL
Minimum version required
  • Version 10
Comments
Click [Add] to post a comment

Last update: 09/02/2025

Send a report | Local help