Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Different Ajax behaviour when run from Apex Builder or stand alone

InoLJun 5 2019 — edited Jun 6 2019

I am running Apex 19.1. I have tried to reproduce my problem on apex.oracle.com, but without success. So, this is a long shot....

The simplified situation is like this.

I have a procedure:

create or replace procedure hello(p_who in varchar2)

as

begin

  sys.htp.p('Hello '||p_who);

end;

An Ajax Callback  process:

hello(:P5_WHO);

A text item: P5_WHO.

A button with a Javascript DA:

hello();

A Javascript function:

function hello() {

    apex.server.process('hello', {

        pageItems: '#P5_WHO'

    }, {

            dataType: "text",

            success: function (pData) {

                console.log("hello result: " + pData);

                if ( pData ) {

                    apex.message.alert(pData);

                }

            }

        });

}

When I run the page from Apex Builder, I get the expected output in the console (Hello ...) and in the alert.

But, when I logout of the Apex Builder and run the page again in stand alone (runtime) mode, there is no pData.

I can also see it in the Developer toolbar of Chrome (network traffic). There is a request:

p_request: APPLICATION_PROCESS=Rekenen_stap1

p_json: {"pageItems":{"itemsToSubmit":[{"n":"P38_PROVISIE_BEHOUDEN","v":"N"}],"protected":"iiVk.....kY","rowVersion":"","formRegionChecksums":[]},"salt":"158854179772644815191688020872545788994"}

There is a response when the application is run from the Apex Builder.

But no response when run stand alone (not from the Builder): "This request has no response data available"

Has anybody else ever seen this behaviour?

Comments

InoL

I changed my procedure to better reflect what is happening in my situation:

create or replace procedure hello(p_who in varchar2)

as

begin

  raise_application_error(-20000,'Hello '||p_who);

end;

And now I can reproduce it. It shows "sqlerrm:ORA-20000: Hello World" when run from the Apex Builder, nothing when run from outside the builder.

It looks like raise_application_error is suppressed in runtime mode. I do have Ajax calls that work fine, but looking a bit closer they don't raise an error, but use htp.p to show the error.

Oleh Tyshchenko

Interestingly LEVEL9 debug shows no difference between APEX and non-APEX sessions. Maybe a bug. As a workaround you may replace your AJAX callback with a Execute PL/SQL Code dynamic action.

J-Lig

Are you sure your AJAX call was actually successful? You might want to add an error callback to the AJAX request. It might be throwing an error but you dont have any actions defined in the event of an error. You only have success defined.

J-Lig

If you've never done that, just copy your success object and paste it after your existing success object. Rename it to error and then change your console log to say something else.

InoL
You might want to add an error callback to the AJAX request.

There is no error, just an empty response.

If there was an error, it would be even worse. That would mean that when the applications runs from the builder, it would return a success, but run from outside the builder it would return an error.

J-Lig

That's exactly what appears to be happening. From within the builder the AJAX call runs your "hello" processes successfully. We know this because it is firing the success actions that you have defined. It does not appear that your "hello" process is running successfully from outside of the builder right now. If it were, you would be seeing your success actions firing. The AJAX call will complete successfully regardless of whether your "hello" process runs successfully or not. In order to see errors thrown by your "hello" process you need to define an error handler. The success and error blocks in the call are to determine whether your "hello" ran successfully. Does that make sense?

InoL

In both situations there is a console log from the success branch:

console.log("hello result: " + pData);

When run from builder: hello result: sqlerrm:ORA-20000: Hello Me

When run from outside the builder: hello result:

So, there is no error.

You can see it on apex.oracle.com:

Workspace: SQLINT

User: OTN

PW: OTN111111

Application: OTN

Page: 5

J-Lig

Oh, got it! Sorry, I thought you were saying it wasn't firing the success actions at all from outside. I thought you were just seeing the error in the developer tools.

Looking at your app, it doesn't appear to pass a value for P5_WHO at all from outside the builder. This might be a bug. I have built these many times and I have never seen that happen before. However, we are still moving to 19 and I haven't written any of these in this version yet. Let me look at a couple more things.

Jen

InoL

The plsql code is:

raise_application_error(-20000,'Hello '||p_who);

If p5_who was not passed, the result would still be "Hello" (without a name), so that is not the problem. You can completely remove the parameter if you want.

It's really just how Apex handles raise_application_error differently when running from the builder or not.

Zoltán

Hello,
What is the solution for the "AjaxCallBack response is empty outside of Builder" problem?
Thanks&Regards

AndyH

It looks like raise_application_error is suppressed in runtime mode. I do have Ajax calls that work fine, but looking a bit closer they don't raise an error, but use htp.p to show the error.
Correct, the Ajax calls are communicating through the http buffer - which isn't impacted by the raise_application_error.

1 - 11

Post Details

Added on Jun 5 2019
11 comments
1,033 views