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!

Showing progress while running a procedure in the back ground

RavitejaJul 4 2019 — edited Jul 26 2019

Hi,

    I'm on Apex 19.1 and I have a page that uploads and parses XLSX file before loading. I created a button that calls a PL/SQL process to load that data into the table(s). This excel file has over 160 columns and over 1000 rows.

When users click on the button, I want to show progress so that they know it's doing something. Ive used the technique listted here https://community.oracle.com/thread/4171805

Now, when the button is clicked, I see the spinner and the procedure runs successfully but I see an error on screen listed below and the spinner keeps on spinning continuously unless I click on some other link and move away from the page. Am I doing something wrong?

"1 error has occurred

    Error: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data"

My Ajax callback process

declare 
begin 
   /* ********************** * 
   * PL/SQL Process Content * 
   * ********************** */ 
  sp_load_file(:P23_FILE); 
      
   apex_json.open_object; 
   apex_json.write('success', true); 
   apex_json.write('message', 'Success'); 
   apex_json.close_object; 
exception 
   when others then 
      apex_json.open_object; 
      apex_json.write('success', false); 
      apex_json.write('message', sqlerrm); 
      apex_json.close_object; 
end; 

My Java Script code under dynamic action:

var lSpinner$ = apex.util.showSpinner(); 

 

apex.server.process("PLS_AJAX", 

                    {pageItems: "#P23_FILE" /*List of the items that are used in your process */ 

                     }, 

                    {success: function( pData ) { 

                        /* If the AJAX is successful */ 

                        if (pData.success === true){ 

                           /* Show success message */ 

                           apex.message.showPageSuccess( pData.message ); 

                        } 

                        else { 

                           /* Show error message */ 

                           apex.message.clearErrors(); 

 

                           apex.message.showErrors([ 

                           { 

                              type:       "error", 

                              location:   "page", 

                              message:    pData.message, 

                              unsafe:     false 

                           } 

                           ]); 

                        } 

                         

                        /* Remove the processing image */ 

                        lSpinner$.remove(); 

                      } 

                     } 

                    ); 

Thank you

This post has been answered by Pavel_p on Jul 11 2019
Jump to Answer
Comments
Post Details
Added on Jul 4 2019
20 comments
4,657 views