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
  • Miscellaneous
  • Older browsers
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
AJAXExecuteAsynchronous (Function)
In french: AJAXExécuteAsynchrone
Runs a server procedure without refreshing the page. This function is not locking. The other processes continue to run (no matter whether the result of the procedure run is retrieved or not).
As soon as the result of the server procedure is available, AJAXExecuteAsynchronous automatically calls a browser procedure used to retrieve this result.
To avoid locking the processes as long as the result of server procedure run is not retrieved, use AJAXExecute.
Example
// Is AJAX supported by the current browser?
IF AJAXAvailable() = True THEN
// Run the server procedure named "MyProc"
// As soon as the result of the "MyProc" server procedure becomes available,
// the "ProcResult" browser procedure will be run
Res is int
Res = AJAXExecuteAsynchronous(MyProc, ProcResult, CustomerName, Bonus)
// The following processes are run without waiting for the result
...
ELSE
// Processes without using AJAX
...
END
// -- MyProc server procedure // --
// Procedure used to find the data to be modified in the page
PROCÉDURE MyProc(CustomerName, RedRate)
// Find data to be modified
...
// Returns the result
RESULT TheResult
// -- ProcResult browser procedure // --
// Procedure automatically called as soon as the result of "MyProc" procedure becomes available
// The "ModifiedData" parameter corresponds to the result of MyProc server procedure
PROCÉDURE ProcResult(ModifiedData, Res)
// Analyze the result and update the modified controls
...
Syntax
<Result> = AJAXExecuteAsynchronous([<Options>, ] <Server procedure> , <Browser procedure> [, <Parameter 1> [... [, <Parameter N>]]])
<Result>: Integer
Identifier of the call to <Server procedure>. This identifier will be used by the other AJAX functions.
<Options>: Integer constant
Update mode:
ajaxPostValueOfControlsThe values of all the controls of the page must be sent to the server. The WLanguage server 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 Ajax call will not use the AWP context. Therefore, this context will not be locked. Used to parallelize the Ajax calls on the server.
Caution: This constant has no effect in page or project GO.
Caution: these constants must be used directly (no variable can be used to store their value).
<Server procedure>: Procedure name
Name of server procedure to run (global or local procedure). This procedure is used to find the data to be modified in the page.
This procedure has the following format:
PROCEDURE <Server procedure> (<Parameter 1>, <Parameter 2>, ...)
This procedure must be allowed to be called by AJAX (see the Notes).
<Browser procedure>: Procedure name
Name of browser procedure (global or local procedure) automatically run as soon as the result of <Server procedure> becomes available.
This procedure has the following format:
PROCEDURE <Browser procedure> (<Result of server procedure>,
<Identifier of server procedure>)
where:
  • <Result of server procedure> is a character string corresponding to the result returned by the <Server procedure>.
  • <Identifier of server procedure> is an integer that corresponds to the identifier of the call to <Server procedure> (<Result> parameter of AJAXExecuteAsynchronous).
<Parameter 1>: Optional character string
First parameter passed to <Server procedure>.
Caution: Only simple types can be used (character string, integer, etc.). Structured types cannot be used.
<Parameter N>: Optional character string
Nth parameter passed to <Server procedure>.
Caution: Only simple types can be used (character string, integer, etc.). Structured types cannot be used.
Remarks

Result of the server procedure

<Server procedure> is used to search for data to be modified in the page. The result of this procedure (which means the data to modify) can be contained in a character string or in an XML document (created and handled by the XML functions).
To send this result back to the browser, use the RETURN keyword and specify:
  • the character string that contains the data.
  • the name of the XML document that contains the data.
<Browser procedure> is automatically run as soon as this result becomes available. The first parameter of <Browser procedure> contains this result. 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.
Remark: When using 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 sites, 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.
To allow a server procedure to be called by AJAX, click "AJAX" in the procedure bar:
Procedure that cannot be called by AJAX
Procedure that can be called by AJAX

Miscellaneous

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: 03/15/2023

Send a report | Local help