3 Replies Latest reply on Nov 4, 2015 12:30 PM by Bernd Alheit

    Only Submit form if Net.HTTP.request is valid

    johnbruso23 Level 1

      Hi All,

       

      Net.HTTP.request is a trusted function I believe. I have to test for network connectivity by testing if my website is available. If it is, the form is submitted. If the network is not available, the form is not submitted.

       

      My problem is I have 2 independent functions. I have this in my submit button:

      var cURL = "http://insite";
      MyNetworkPing(cURL);


          this.submitForm({
           cURL: "http://insite/PDFFormProcessing_TestJB.cfm#FDF",
           cSubmitAs: "HTML"
               });

       

      Trusted JavaScript .js file that lives in C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Javascripts:

       

        var MyNetworkPing = app.trustedFunction(function(cURL){

        app.beginPriv();

       

         var params =

           {

         cVerb: "MKCOL",

         cURL: cURL,

         oHandler:

          {

          response: function(msg, uri, e)

           {

           // HTTP 405 - Can't MKCOL if it exists!

           if(e != undefined && e.error != 405) {

           app.alert("This Form is not connected to the network or Insite is unavailable. Please choose Save As to save your form to your desktop and resubmit once you've connected to the PRECorp Network: "+ e);

           } else app.alert("Ping http://insite Successful");

          

          }

           }

         };

         Net.HTTP.request(params);

        

         app.endPriv();

        });

       

       

      How do I make the submitForm dependent on the success of the MyNetworkPing function when the ohandler is successful ? Is there a session variable I can set?