2 Replies Latest reply on Aug 14, 2012 8:07 AM by thomas_th21

    postNetText and netDone

    thomas_th21

      Hello,

       

      I have a question about the postNetText and the netDone command.

      In my case I would like to send a string to a server using the postNetText command.

      This is no problem. The command send my information to a PHP file.

      The problem is that I would like to show some feedback with error messages.

      I found on the internet that you can do this with the netDone command.

      The problem is that as the file send correct, the netDone keep giving me the error message.

      If I use a breakpoint everything is ok and the netDone gives me a correct output.

       

      some code:

       

      here I send my information (this is ok)

       

      gNetID = postNetText("http://dev-site.com/telesiminar/save.php",tData)

       

      On the exit of the frame he always go to the else statement (even if the file sended correct)

       

      on exitFrame me

        if myWebLock = true then

          if (netDone(gNetID) = TRUE) and (netError(gNetID) = "OK") then

            alert "it is ok !"

            myWebLock = false

          else

            alert "failed to send reason: " & dumpNetError(netError(gNetID))

            myWebLock = false

          end if

        end if

      end

       

      What can be my mistake ?

        • 1. Re: postNetText and netDone
          James Newton, ACP Level 3

          You are checking netError() even if the upload is not complete. Perhaps you should wait until netDone() returns TRUE before checking netError(). Under certain circumstances, netError() may return "" or 0. It is best to check for a non-zero integer, to be sure that the result indicates a true error.

           

          on exitFrame me

            if myWebLock = TRUE then

              if (netDone(gNetID) = TRUE) then

                -- The server has returned a result, either success or failure


                vError = netError(gNetID)


                if not integerP(vError) then

                  -- Convert "" and "OK" to 0 = no error

                  vError = 0

                end if -- integerP(vError)


                if not vError then

                  alert "it is ok !"


                else

                  alert "failed to send reason: " & dumpNetError(vError)

                end if -- vError


                myWebLock = FALSE

              end if -- netDone()

            end if -- myWebLock

          end

          • 2. Re: postNetText and netDone
            thomas_th21 Level 1

            Thank you

            Indeed that solved the problem