4 Replies Latest reply on Feb 15, 2011 12:58 AM by vishalkumar86

    XMLHttpRequest

    vishalkumar86

      Hi All,

       

           I am facing  issue in excessing XMLHttpRequest class object in my flex  application.

           Currently, I am embedding the javascript method inside my flex application rather than in a separate js file and call that using external interface.

           When I create an instance of XMLHttpRequest class inside that js method of my flex application, nothing happens, but if I put that method in a separate js

           file , then that works fine.

           Any help will be appreciated.

           -Thanks in advance

        • 1. Re: XMLHttpRequest
          Flex harUI Adobe Employee

          Show some code.  I don't understand what it means to embed JS in a flex app.

          • 2. Re: XMLHttpRequest
            vishalkumar86 Level 1

            Hi ,

             

            Thanks for the response.

             

            here is some code:

            private static var FUNCTION_DELETE : String =
               "function (inStr, inAuthHeader, verb)" +
               "{" +
                "var xhr = new XMLHttpRequest();" +
                "xhr.onreadystatechange = function() " +
                "{" +
                 "if (xhr.readyState==4) " +
                 "{" +
                  "if (xhr.status == 204)" +
                  "{" +
            //       some method
                  "}" +
                 "}" +
                "}" +
                "xhr.open(verb, inStr, true);" +
                "xhr.setRequestHeader('Authorization, Basic '+inAuthHeader);" +
                "xhr.send();" +
               "}";

             

            ExternalInterface.call(FUNCTION_DELETE, str, encodedString, verb);

            where verb is "DELETE".

             

             

             

             

            • 3. Re: XMLHttpRequest
              Flex harUI Adobe Employee

              I don't see any mention in the doc that you can pass the code for a function

              as the first parameter to ExternalInterface.call.  Where did you see that?

               

              Normally the function is in the HTML wrapper.  You could have a generic

              function in the wrapper that would set up this function first then call it

              later.

              • 4. Re: XMLHttpRequest
                vishalkumar86 Level 1

                Hi,

                Thanks for the reply,

                 

                After doing some googling, I found that one and that works fine, if we add  js alert inside that code.

                By the way, If the user wants to add authentication headers and pass that via external interface to the js  and call xmlhttprequest for some url, then it might be possible to intercept that username and password.

                 

                -Thanks