3 Replies Latest reply on Aug 2, 2007 1:57 PM by batmitra

    HTTPService: How can I send a variable or call a function in it?

    xehod
      Ok i have the following HTTPService request:

      <mx:HTTPService id="userRequest" url=" http://mywebsite/get_data.php" useProxy="false" method="POST">
      <mx:request xmlns="">
      <user1>{username.text}</user1>
      </mx:request>
      </mx:HTTPService>

      Pretty straight forward stuff there. EXCEPT... i want to use a variable instead of 'username.text...
      <user1>{UserNameList[0]}</user1>

      OR i want to be able to call a function that will return the results such as:
      <user2>{ UserFunction() }</user2>

      Of course, neither of these work and this makes me sad :(
      Anyone have any ideas? Much appreciated~!
        • 1. Re: HTTPService: How can I send a variable or call a function in it?
          batmitra Level 1
          hi
          when you call your HTTPSERVICE you can do what you want because in fact you want to send it a parameter, so , don't use the request tag of mxml you can use like this:

          Supose you have a button that is a submit button and you call it mysubmitbutton, when you click that button , on your mxm you should have this:

          <mx:button id ="mysubmittbutton" click="{userRequest.send(yourparameter)}"/>
          • 2. Re: HTTPService: How can I send a variable or call a function in it?
            xehod Level 1
            <mx:button id ="mysubmittbutton" click="{userRequest.send(yourparameter)}"/>

            Problem with that, is my php script is looking for $_POST['user1'] ...
            If I do what you are saying, it does not recognize the Posted info as user1 data.

            I am unsure how to get my results in the php file.
            • 3. Re: HTTPService: How can I send a variable or call a function in it?
              batmitra Level 1
              on that i can't help
              i'm a .net programmer an i use a lot httpservices but mostly i use webservices to get my data.

              But i can give my way of working. When you send your data from flex you are sending a virtual xml file thru http, then in .net using it xml class i read this stream of xml coming from flex, go to my database, get the result , wrapped it in xml and send thru stream again, so that flex understands the answer. When it gets to flex i just use e4x to read my data.

              There are tons of tutorials on the net for PHP, i wish i had half for .Net :D