admin管理员组文章数量:1313779
I am using Oracle 11g with Oracle Apex v4.2.2 and I was wondering how the best way to call an Oracle function via an ajax call, within a Dynamic Action.
I basically have a function that takes six parameters that either returns the result of 'INVALID' or 'VALID'.
Within my page, I want to be able to accept the values that the user has entered and once they press the button to process, I need to check via ajax whether the result was 'INVALID' or 'VALID' and immediately present the user with a dialog box notifying them that there was an error.
Is there a new means of processing this type of ajax request to call a function, within Oracle APEX v4.2.2?
I am using Oracle 11g with Oracle Apex v4.2.2 and I was wondering how the best way to call an Oracle function via an ajax call, within a Dynamic Action.
I basically have a function that takes six parameters that either returns the result of 'INVALID' or 'VALID'.
Within my page, I want to be able to accept the values that the user has entered and once they press the button to process, I need to check via ajax whether the result was 'INVALID' or 'VALID' and immediately present the user with a dialog box notifying them that there was an error.
Is there a new means of processing this type of ajax request to call a function, within Oracle APEX v4.2.2?
Share Improve this question edited Dec 16, 2018 at 17:35 halfer 20.3k19 gold badges109 silver badges202 bronze badges asked Jan 31, 2014 at 7:05 tonyftonyf 35.6k53 gold badges165 silver badges260 bronze badges1 Answer
Reset to default 5Ajax + apex 4.2 = apex.server.process api
It requires you have a process at the on-demand process point of the page or an application process. In it you have to call your function and provide the parameters, which can be the page items. To provide a return, write values to the http buffer with calls to htp.p
.
DECLARE
some_var1 VARCHAR2(50);
BEGIN
some_var1 := my_package.my_function(:P1_EMPNO, :P1_DEPTNO);
-- write values back
htp.p(some_var1);
END;
You can easily provide apex.server.process
with page items. Further handling is all in javascript.
Note of warning: the dataType is by default set to JSON, and thus if you provide no other default datatype and do not return a json string you will get a parsing error. So if you return a text within your on-demand process such as INVALID, make sure to set the datatype to text!
apex.server.process ( "MY_PROCESS", {
pageItems: "#P1_DEPTNO,#P1_EMPNO"
}, {
dataType: "text"
, success: function( pData ) {
//pData should contain VALID or INVALID - alert it
alert(pData);
if ( pData === 'INVALID' ) {
// do something here when the result is invalid
// maybe you want to color something red for example
alert('The data you have entered is invalid');
};
}
} );
I wouldn't split this up in more dynamic actions than necessary, even though it might be possible. I personally am not fond of trying to use a PLSQL block dynamic true action, just because it is more obscure to act on if you want to deal with return values.
Just set your button to not submit the page, but action defined by dynamic action. Then in the dynamic action create one true action of type execute javascript, and use the ajax call with callback(s) there.
本文标签:
版权声明:本文标题:javascript - Calling an Oracle function via Ajax for on-the-spot validation purposes in Oracle APEX v4.2.2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741956499a2407018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论