Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ajaxCall in dedicated web worker thread
#2
The following problem occurred in the main thread when testing the AJAX callback TIWCallbackProc2:

TIWCallbackProc2 = reference to procedure (aParams: TStrings; out aResult: string);

ajaxCall("Multiply", "&x=5&y=10", false, function(response) {alert("Result is: " + response);});

In the above example, the callback function receives 2 parameters named x and y, and multiply them.
The result is put into aResult parameter (which is an out parameter).
The difference here compared to old versions is that aResult string is returned to the browser as is, i.e.
the response will contain a string representing the result of the multiplication of x by y only, nothing else.
This makes much easier to interface with existing JavaScript libraries which expect specific responses (e.g. JSON strings).

In fact, when a valid result is returned from the server, the browser only gets that one string, and that's really easy to deal with.
However, if no valid result is provided by the server, the browser receives the following output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><response>

<update>

</update>

<submit>/</submit>

<trackid>29</trackid></response>

Since something is always delivered, the evaluation of the result is not that easy.


The following problem occurred in the main thread when testing the AJAX callback TIWCallbackProc3:

TIWCallbackProc3 = reference to procedure (aParams: TStrings; out aResult: string; out aHandled: Boolean)

The forth type of callback (TIWCallbackProc3) is the most flexible one.
It allows you to set the result directly using variable aResult (as above) or still use TIWApplication.CallbackResponse object (as in IW 15.0), or yet,
bypass the response completely setting aHandled parameter to True.
Setting aHandled to True means that the user code is responsible for creating the reponse.
In this case, IntraWeb will skip the execution of callback response code completely.

If the parameter aHandled = true is set on the server, you get a message box with the error message: "Uninitialized reply",,
which can be prevented by the following call:

UserSession()->WebApplication->Response->Code = 200;

However, the AJAX response function is still called, but with an empty response!


C++Builder 11.0
Intraweb 15.2.50
Reply


Messages In This Thread
RE: ajaxCall in dedicated web worker thread - by JuergenS - 02-23-2022, 10:14 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)