5 Replies Latest reply: Apr 28, 2014 6:23 PM by Sai6896 RSS

    Success Message through Javascript Function

    Sai6896


      Hello,


      I have an Ajax call to call a Process Like this


      var ajaxRequest = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=ProcessName',10);

       ajaxResult = ajaxRequest.get();

        if (ajaxResult == 'Success')

      {

       redirect("f?p=&APP_ID.:88:&SESSION.::NO::");

      }

      else{

       alert(ajaxResult);

      }


      So when ajaxResult is "Success" i need to redirect to an other page and Show Some Success Notification there ,Something like "Action Processed" in the Success Message Notification area

      .


      Can anyone help me out in this please.


      Thanks,

      Sai.


        • 1. Re: Success Message through Javascript Function
          jrimblas

          Sai,

          The code looks fine, what exactly is the problem?

           

          Is your PL/SQL returning Success via an htp.prn call?

          If you do htp.p('Succes'); then you actually get a new line character included and (ajaxResult == 'Success') will never be true.

          Try htp.prn instead.

           

          Thanks

          -Jorge

          • 2. Re: Success Message through Javascript Function
            Sai6896

            Hi Jorge,

             

            My problem here is im redirecting to other page successfully but i need to show the Success message Like "Action Processed." in that redirected page.

             

            usally when its a regular on submit PLSQL process, we can create a branching and say include success message , but since this is an on demand ajax call process hwo to include success message??

             

            Thanks,

            Sai.

            • 3. Re: Success Message through Javascript Function
              jrimblas

              Hi Sai,

              I' struggling with the fact that what you're describing is exactly what APEX does natively with no hassles if you place your AJAX code in a Process and then branch to a new page on success.

              Why do you need the AJAX process in this case?

               

              That said, once you start replicating native behavior on your own you need to keep on adding more and more code.  So here are some ideas:

              * If you ONLY arrive at p88 after success then add a region to your page that has the same HTML as the Success message of your page template.  For example, for Theme 25, my HTML content would look something like this:

              <div class="apex_grid_container">

                <div class="apex_cols apex_span_12">

                  <section class="uMessageRegion successMessage clearfix" id="uSuccessMessage">

                    <div class="uRegionContent clearfix">

                      <a href="javascript:void(0)" onclick="apex.jQuery('#uSuccessMessage').remove();" class="uCloseMessage"><span class="visuallyhidden">#CLOSE_NOTIFICATION#</span></a>

                      <img src="#IMAGE_PREFIX#f_spacer.gif" class="uCheckmarkIcon" alt="" />

                      <div class="uMessageText">

                        Action Processed

                      </div>

                    </div>

                  </section>

                </div>

              </div>

               

              Of course you could make it conditional.  For example, only show it with a specific request value.  Lest say SUCCESS.  Then your redirect after the AJEX call would look like this:

              redirect("f?p=&APP_ID.:88:&SESSION.:SUCCESS:NO::");

              Then the region only shows when the arriving request is success.

               

              * You could also inject the success message HTML via javascript.  But again, that gets messy.

               

              Thanks

              -Jorge

              • 4. Re: Success Message through Javascript Function
                GhanaApexDeveloper

                Hi your code looks ok, but exatcly what is the application process doing?? Besides who do u trigger this success in the first place?

                Thanks Benjamin

                • 5. Re: Success Message through Javascript Function
                  Sai6896

                  Thank you Jorge.