4 Replies Latest reply on Mar 14, 2007 6:28 PM by csawall

    Using data from HTTPService call

    csawall Level 1
      I have been searching every forum, Google, etc for what I'm trying to do. I have found some answers, but none of them seem to work for me or I'm doing something wrong (probably the latter).

      I have a simple app that presents a form to a user and based on their input it makes and HTTPService call to send a GET to a PHP script which then returns data to fill a datagrid and present a chart. That all works good. Now I'm trying to figure out the best way to export the data to a CSV. I've seen the forums that show how to put the data to a clipboard and then copy it. I can't get any of those to work for some reason. I had another idea, but can't figure out how to do it.

      I'd like to take the same query and returned results and put it into a string or similar so I can output the data to a TextArea. Is this possible? I've got the popup working and when I can get it to fill in the TextArea, it just says "[Object,object],[Object,object]...... " over and over again. So it's almost like the data is getting there, but it's not displaying properly. Any thoughts on how to do this?

      Is the data returned from a query like this an Array? An XMLList? I can't find any docs on how to determine what the result is returned as or how to use the result other than in a datagrid or filling in Labels or Text fields.

      Any help would be greatly appreciated.

      Thanks,
      chris
        • 1. Re: Using data from HTTPService call
          ntsiii Level 3
          First this forum is intended for questions about Flex Builder. Flex language questions should be posted in the Flex General Discussion forum.

          The default resultFormat of HTTPService is an mx:Object. Flex takes your xml and converts it to a nested object structure. I personally do not like this and have moved exclusively to resultFormat="e4x" this returns an XML node that is the root of your data.

          If you are already using a resultHandler function to receive your data, then you are in good shape, if not, then you will need to implement this in order to do the processing you want.

          The [object Object] you see is caused when you are attempting to view a complex object in a control that needs to display a string. this means your reference to the data is not quite right.

          I have used the System.setClipboard() call successfully many times. What problem are you having?

          I assume the PHP is returning xml? What do you see if you hit the php url directly in a browser?

          Tracy
          • 2. Re: Using data from HTTPService call
            csawall Level 1
            Tracy - Thank you for taking the time to reply. Sorry about posting to the wrong forum. I was busy reading so many other posts, I just hit the link to add a new topic.

            You are right, my first problem was how to use the returned data. I found another post that said to use the e4x format, just like you said and that definitely helped. I found this example on manipulating XML data: http://www.brucephillips.name/blog/index.cfm/2006/10/15/XML-Tutorial-Part-2, which also help.

            With all of this, I am able to take the XML output and dump it right into the TextArea for viewing or selecting and copying.

            What I'd like to do now though is to pull off the XML tags and just have the straight content so that I can have usable CSV text to copy.

            As for the System.setClipboard() call - I guess I didn't have so much trouble with that other than figuring out how to get the data out of my datagrid properly, convert it to a string to create a CSV format and then copy it.

            Chris
            • 3. Re: Using data from HTTPService call
              ntsiii Level 3
              Ok, how is your xml formatted? That will determine exactly how you build your csv string.

              Post a bit of the xml and the csv string result you want, and I'll suggest a solution.

              Or move this over to General discussion, I don't always check this forum.

              Tracy